Yitzchak Scott-Thoennes | 7 Feb 2005 00:01
Favicon
Gravatar

Re: gethostbyname() problem?

On Sun, Feb 06, 2005 at 12:05:30PM +0100, Corinna Vinschen wrote:
> On Feb  6 00:35, Brian Dessent wrote:
> > -  static int a, b, c, d;
> > +  static int a, b, c, d, n;
> >  
> >    sig_dispatch_pending ();
> >    if (check_null_str_errno (name))
> >      return NULL;
> >  
> > -  if (sscanf (name, "%d.%d.%d.%d", &a, &b, &c, &d) == 4)
> > +  if (sscanf (name, "%d.%d.%d.%d%n", &a, &b, &c, &d, &n) == 4 && (unsigned)n == strlen (name))
>
> Thanks for the patch, Brian.  Do you also have a nice ChangeLog entry
> for me?

I've always done this like below; then the n==strlen(name) check isn't
needed (since the ==4 verifies that %c wasn't used).  Even using the
%n, there's no reason to make n static, is there?

2005-02-06  Yitzchak Scott-Thoennes <sthoenna <at> efn.org>

	* net.cc (cygwin_gethostbyname): Treat as hostname even if
	beginning with "%d.%d.%d.%d"

--- winsup/cygwin/net.cc.orig	2004-04-11 10:41:17.000000000 -0700
+++ winsup/cygwin/net.cc	2005-02-06 13:49:42.783942400 -0800
 <at>  <at>  -997,12 +997,13  <at>  <at>  cygwin_gethostbyname (const char *name)
   static char *tmp_aliases[1];
   static char *tmp_addr_list[2];
   static int a, b, c, d;
(Continue reading)

Christopher Faylor | 7 Feb 2005 00:44
Favicon

Re: gethostbyname() problem?

On Sun, Feb 06, 2005 at 03:01:29PM -0800, Yitzchak Scott-Thoennes wrote:
>On Sun, Feb 06, 2005 at 12:05:30PM +0100, Corinna Vinschen wrote:
>> On Feb  6 00:35, Brian Dessent wrote:
>> > -  static int a, b, c, d;
>> > +  static int a, b, c, d, n;
>> >  
>> >    sig_dispatch_pending ();
>> >    if (check_null_str_errno (name))
>> >      return NULL;
>> >  
>> > -  if (sscanf (name, "%d.%d.%d.%d", &a, &b, &c, &d) == 4)
>> > +  if (sscanf (name, "%d.%d.%d.%d%n", &a, &b, &c, &d, &n) == 4 && (unsigned)n == strlen (name))
>>
>> Thanks for the patch, Brian.  Do you also have a nice ChangeLog entry
>> for me?
>
>I've always done this like below; then the n==strlen(name) check isn't
>needed (since the ==4 verifies that %c wasn't used).  Even using the
>%n, there's no reason to make n static, is there?

There has been no reason to make a, b, c, d static either AFAICT.
This whole function is frightfully non-reentrant, but I knew that.

cgf

Yitzchak Scott-Thoennes | 7 Feb 2005 06:53
Favicon
Gravatar

Re: gethostbyname() problem?

On Sun, Feb 06, 2005 at 06:44:58PM -0500, Christopher Faylor wrote:
> On Sun, Feb 06, 2005 at 03:01:29PM -0800, Yitzchak Scott-Thoennes wrote:
> >On Sun, Feb 06, 2005 at 12:05:30PM +0100, Corinna Vinschen wrote:
> >> On Feb  6 00:35, Brian Dessent wrote:
> >> > -  static int a, b, c, d;
> >> > +  static int a, b, c, d, n;
> >> >  
> >> >    sig_dispatch_pending ();
> >> >    if (check_null_str_errno (name))
> >> >      return NULL;
> >> >  
> >> > -  if (sscanf (name, "%d.%d.%d.%d", &a, &b, &c, &d) == 4)
> >> > +  if (sscanf (name, "%d.%d.%d.%d%n", &a, &b, &c, &d, &n) == 4 && (unsigned)n == strlen (name))
> >>
> >> Thanks for the patch, Brian.  Do you also have a nice ChangeLog entry
> >> for me?
> >
> >I've always done this like below; then the n==strlen(name) check isn't
> >needed (since the ==4 verifies that %c wasn't used).  Even using the
> >%n, there's no reason to make n static, is there?
> 
> There has been no reason to make a, b, c, d static either AFAICT.
> This whole function is frightfully non-reentrant, but I knew that.

Better?  Reentrancy isn't actually required, but no reason not to do it.
I have compiled net.cc but not done any other testing.  Did I mention
that dup_ent is really neat?

2005-02-06  Yitzchak Scott-Thoennes <sthoenna <at> efn.org>

(Continue reading)

Christopher Faylor | 7 Feb 2005 07:13
Favicon

Re: gethostbyname() problem?

On Sun, Feb 06, 2005 at 09:53:48PM -0800, Yitzchak Scott-Thoennes wrote:
>On Sun, Feb 06, 2005 at 06:44:58PM -0500, Christopher Faylor wrote:
>> On Sun, Feb 06, 2005 at 03:01:29PM -0800, Yitzchak Scott-Thoennes wrote:
>> >On Sun, Feb 06, 2005 at 12:05:30PM +0100, Corinna Vinschen wrote:
>> >> On Feb  6 00:35, Brian Dessent wrote:
>> >> > -  static int a, b, c, d;
>> >> > +  static int a, b, c, d, n;
>> >> >  
>> >> >    sig_dispatch_pending ();
>> >> >    if (check_null_str_errno (name))
>> >> >      return NULL;
>> >> >  
>> >> > -  if (sscanf (name, "%d.%d.%d.%d", &a, &b, &c, &d) == 4)
>> >> > +  if (sscanf (name, "%d.%d.%d.%d%n", &a, &b, &c, &d, &n) == 4 && (unsigned)n == strlen (name))
>> >>
>> >> Thanks for the patch, Brian.  Do you also have a nice ChangeLog entry
>> >> for me?
>> >
>> >I've always done this like below; then the n==strlen(name) check isn't
>> >needed (since the ==4 verifies that %c wasn't used).  Even using the
>> >%n, there's no reason to make n static, is there?
>> 
>> There has been no reason to make a, b, c, d static either AFAICT.
>> This whole function is frightfully non-reentrant, but I knew that.
>
>Better?

Yes, I think it is much better.  I know that this doesn't have to be
non-reentrant but it should be thread safe, IMO.

(Continue reading)

Corinna Vinschen | 7 Feb 2005 10:38
Picon
Favicon

Re: gethostbyname() problem?

On Feb  7 01:13, Christopher Faylor wrote:
> On Sun, Feb 06, 2005 at 09:53:48PM -0800, Yitzchak Scott-Thoennes wrote:
> >Reentrancy isn't actually required, but no reason not to do it.  I have
> >compiled net.cc but not done any other testing.  Did I mention that
> >dup_ent is really neat?
> 
> Thank you.  That solved a few problems when I implemented it.
> 
> You'd think it would have occurred to me that you could use it in this
> context.
> 
> This is fine with me, if it is ok with Corinna.

I like it, but it's a bit over the border for a trivial patch.  I'd be
willing to let slip this through, though.  Yitzchak, any plans to send
a copyright assignment form to Red Hat?  That would be nice and would
keep me from further ticking off. ;-)

However, CVS seems to be broken somehow.  I can't check it in.  Stay
tuned.

Corinna

--

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          mailto:cygwin <at> cygwin.com
Red Hat, Inc.

Christopher Faylor | 7 Feb 2005 16:37
Favicon

Re: gethostbyname() problem?

On Mon, Feb 07, 2005 at 10:38:23AM +0100, Corinna Vinschen wrote:
>On Feb  7 01:13, Christopher Faylor wrote:
>> On Sun, Feb 06, 2005 at 09:53:48PM -0800, Yitzchak Scott-Thoennes wrote:
>> >Reentrancy isn't actually required, but no reason not to do it.  I have
>> >compiled net.cc but not done any other testing.  Did I mention that
>> >dup_ent is really neat?
>> 
>> Thank you.  That solved a few problems when I implemented it.
>> 
>> You'd think it would have occurred to me that you could use it in this
>> context.
>> 
>> This is fine with me, if it is ok with Corinna.
>
>I like it, but it's a bit over the border for a trivial patch.  I'd be
>willing to let slip this through, though.  Yitzchak, any plans to send
>a copyright assignment form to Red Hat?  That would be nice and would
>keep me from further ticking off. ;-)
>
>However, CVS seems to be broken somehow.  I can't check it in.  Stay
>tuned.

I wanted to find out what was wrong with CVS, so I just tried checking this
in.  I had no problems fortunately (or unfortunately, depending on how you
look at it).

cgf

Corinna Vinschen | 7 Feb 2005 16:45
Picon
Favicon

Re: gethostbyname() problem?

On Feb  7 10:37, Christopher Faylor wrote:
> On Mon, Feb 07, 2005 at 10:38:23AM +0100, Corinna Vinschen wrote:
> >On Feb  7 01:13, Christopher Faylor wrote:
> >> On Sun, Feb 06, 2005 at 09:53:48PM -0800, Yitzchak Scott-Thoennes wrote:
> >> >Reentrancy isn't actually required, but no reason not to do it.  I have
> >> >compiled net.cc but not done any other testing.  Did I mention that
> >> >dup_ent is really neat?
> >> 
> >> Thank you.  That solved a few problems when I implemented it.
> >> 
> >> You'd think it would have occurred to me that you could use it in this
> >> context.
> >> 
> >> This is fine with me, if it is ok with Corinna.
> >
> >I like it, but it's a bit over the border for a trivial patch.  I'd be
> >willing to let slip this through, though.  Yitzchak, any plans to send
> >a copyright assignment form to Red Hat?  That would be nice and would
> >keep me from further ticking off. ;-)
> >
> >However, CVS seems to be broken somehow.  I can't check it in.  Stay
> >tuned.
> 
> I wanted to find out what was wrong with CVS, so I just tried checking this
> in.  I had no problems fortunately (or unfortunately, depending on how you
> look at it).

Weird.  No it works again.  When I tried it this morning, I got strange
messages (which I neither saved nor recall unfortunately).  I was unable
to access you latest patches and I was unable to checkout a fresh copy
(Continue reading)

Mark Paulus | 7 Feb 2005 17:34
Picon

patch to allow touch to work on HPFS (and others, maybe??)

Attached is a patch that works to allow me to do a 
touch on my mounted HPFS filesystem.  I'm not sure
about clearcase, or others, but it works on HPFS and
NTFS. 

	* times.cc: Use GENERIC_WRITE instead of FILE_WRITE_ATTRIBUTES.

Attachment (times.cc.patch): application/octet-stream, 582 bytes
Corinna Vinschen | 7 Feb 2005 18:19
Picon
Favicon

Re: patch to allow touch to work on HPFS (and others, maybe??)

On Feb  7 09:34, Mark Paulus wrote:
> Attached is a patch that works to allow me to do a 
> touch on my mounted HPFS filesystem.  I'm not sure
> about clearcase, or others, but it works on HPFS and
> NTFS. 
> 
> 	* times.cc: Use GENERIC_WRITE instead of FILE_WRITE_ATTRIBUTES.

That's reverting a more than three years old patch.  Please read
http://cygwin.com/ml/cygwin/2001-08/msg00666.html which explains why
opening with GENERIC_WRITE is not generally a good idea.  If you want
to get it working for HPFS or whatever, use the FS flags present in
the local path_conv variable called win32 to conditionalize the call.

Corinna

--

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          mailto:cygwin <at> cygwin.com
Red Hat, Inc.

Mark Paulus | 7 Feb 2005 22:37
Picon

Re: patch to allow touch to work on HPFS (and others, maybe??)

So, what it really seems to boil down to is 
for those filesystems that support doing timestamp 
updating via FILE_WRITE_ATTRIBUTES (NTFS systems)
we should use FILE_WRITE_ATTRIBUTES, and for those that
don't (HPFS, etc), they should use GENERIC_WRITE?

Unfortunately, during my brief perusal of MSDN, I didn't see
an easy way to determine the file system type.  

I also see from the message you quoted that ntsec comes 
into play, but I think it still goes back to the filesystem, since
I have ntsec set, and the touch works on my box (using NTFS,
on our PDS shares (also running NTFS, I assume), but not
on my OS2/HPFS box.

On Mon, 07 Feb 2005 18:19:25 +0100, Corinna Vinschen wrote:

>On Feb  7 09:34, Mark Paulus wrote:
>> Attached is a patch that works to allow me to do a 
>> touch on my mounted HPFS filesystem.  I'm not sure
>> about clearcase, or others, but it works on HPFS and
>> NTFS. 
>> 
>> 	* times.cc: Use GENERIC_WRITE instead of FILE_WRITE_ATTRIBUTES.

>That's reverting a more than three years old patch.  Please read
>http://cygwin.com/ml/cygwin/2001-08/msg00666.html which explains why
>opening with GENERIC_WRITE is not generally a good idea.  If you want
>to get it working for HPFS or whatever, use the FS flags present in
>the local path_conv variable called win32 to conditionalize the call.
(Continue reading)


Gmane