minor fixes for tzcode1996o

Todd C. Miller Todd.Miller at cs.colorado.edu
Mon Jan 20 23:41:36 UTC 1997


In message <199701202209.RAA03151 at flower.nci.nih.gov>
	so spake  (ado):

> There's a problem if the number of characters in a to-be-generated
> full file name (exclusive of the trailing '\0') equals or exceeds the size of
> the filename buffer.  The number of characters (exclusive of the trailing '\0
> ')
> is
> 	strlen(p) + strlen(name) + 1
> (where the "1" is for the slash that separates the directory from the name)
> and the size of the filename buffer is
> 	sizeof fullname
> It looks to me as if the above test is correct; does anyone see something I'v
> e
> missed?

But why don't you count the trailing '\0'?  You need to guarantee
that the string can be NULL-terminated, right?  That's why I think it
should be +2, not +1.

> > --- time/zic.c	Wed Jan 15 16:41:36 1997
> > ...
> > -	while ((c = getopt(argc, argv, "d:l:p:L:vsy:")) != -1)
> > +	while ((c = getopt(argc, argv, "d:l:p:L:vsy:")) != EOF)
> 
> If anyone knows a good way of conditionalizing this (to cope with, for exampl
> e,
> SunOS 4.1.1), I'd appreciate hearing from you.

Solaris gets this wrong, too but POSIX does say that getopt(3)
should return -1 on error or when no more args.  However, most
OS's define EOF to be -1 so the -1 should work for legacy systems
as well.

 - todd



More information about the tz mailing list