Re: Regression tests for usr.sbin/zic and lib/libc/stdtime

2008-04-02 Thread Steven Kreuzer
On Wed, Apr 02, 2008 at 10:54:08PM +1100, Edwin Groothuis wrote:
 Greetings,
 
 I have make an attempt to upgrade the code in usr.sbin/zic and
 lib/libc/stdtime from tzcode2004 to tzcode2008a. So far so good: I
 have been able to apply most of the patches, it compiles and when
 I rebooted the machine it came back and all applications started
 up... Note that this is a 32 bit machine and that the interesting
 stuff is happening on 64 bitters.
 
 I would like to know if somebody has ever thought about what kind
 of regression tests I can make to be sure that it all works as
 expected once (if ever) this patch-set gets applied.
 
 Edwin

Hey Edwin-

If you would like some help with the testing, please let me know. I have
actually been going through the codebase and started replace sprintf
with snprintf.

I have a patch for zic. Perhaps this can also be included in the modifications
you are currently working on?

--
Steven Kreuzer
http://www.exit2shell.com/~skreuzer
Index: zic.c
===
RCS file: /usr/share/cvs/freebsd/src/usr.sbin/zic/zic.c,v
retrieving revision 1.18
diff -u -r1.18 zic.c
--- zic.c   3 Dec 2007 10:45:44 -   1.18
+++ zic.c   25 Mar 2008 22:27:15 -
@@ -959,7 +959,7 @@
}
if (strcmp(fields[ZF_NAME], TZDEFAULT) == 0  lcltime != NULL) {
buf = erealloc(buf, (int) (132 + strlen(TZDEFAULT)));
-   (void) sprintf(buf,
+   (void) snprintf(buf, sizeof(buf),
 _(\Zone %s\ line and -l option are mutually exclusive),
TZDEFAULT);
error(buf);
@@ -967,7 +967,7 @@
}
if (strcmp(fields[ZF_NAME], TZDEFRULES) == 0  psxrules != NULL) {
buf = erealloc(buf, (int) (132 + strlen(TZDEFRULES)));
-   (void) sprintf(buf,
+   (void) snprintf(buf, sizeof(buf),
 _(\Zone %s\ line and -p option are mutually exclusive),
TZDEFRULES);
error(buf);
@@ -979,7 +979,7 @@
buf = erealloc(buf, (int) (132 +
strlen(fields[ZF_NAME]) +
strlen(zones[i].z_filename)));
-   (void) sprintf(buf,
+   (void) snprintf(buf, sizeof(buf),
 _(duplicate zone name %s (file \%s\, line %d)),
fields[ZF_NAME],
zones[i].z_filename,
@@ -1451,7 +1451,7 @@
}
fullname = erealloc(fullname,
(int) (strlen(directory) + 1 + strlen(name) + 1));
-   (void) sprintf(fullname, %s/%s, directory, name);
+   (void) snprintf(fullname, sizeof(filename), %s/%s, directory, name);
 
/*
 * Remove old file, if any, to snap links.
@@ -1546,7 +1546,7 @@
if (strchr(format, '/') == NULL) {
if (letters == NULL)
(void) strcpy(abbr, format);
-   else(void) sprintf(abbr, format, letters);
+   else(void) snprintf(abbr, sizeof(abbr), format, letters);
} else if (isdst)
(void) strcpy(abbr, strchr(format, '/') + 1);
else {
@@ -1887,7 +1887,7 @@
if (type == NULL || *type == '\0')
return TRUE;
buf = erealloc(buf, (int) (132 + strlen(yitcommand) + strlen(type)));
-   (void) sprintf(buf, %s %d %s, yitcommand, year, type);
+   (void) snprintf(buf, sizeof(buf), %s %d %s, yitcommand, year, type);
result = system(buf);
if (WIFEXITED(result)) switch (WEXITSTATUS(result)) {
case 0:
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]

Re: Regression tests for usr.sbin/zic and lib/libc/stdtime

2008-04-02 Thread Steven Kreuzer
On Wed, Apr 02, 2008 at 06:27:25PM +0400, Andrew Pantyukhin wrote:
 On Wed, Apr 02, 2008 at 09:57:46AM -0400, Steven Kreuzer wrote:
  -   (void) sprintf(fullname, %s/%s, directory, name);
  +   (void) snprintf(fullname, sizeof(filename), %s/%s, directory, name);

 Has a typo crawled in?

Yes it did. Thanks for catching that.
The attached patch corrects that typo.

-- 
Steven Kreuzer
http://www.exit2shell.com/~skreuzer
Index: zic.c
===
RCS file: /usr/share/cvs/freebsd/src/usr.sbin/zic/zic.c,v
retrieving revision 1.18
diff -u -r1.18 zic.c
--- zic.c   3 Dec 2007 10:45:44 -   1.18
+++ zic.c   26 Mar 2008 16:27:43 -
@@ -959,7 +959,7 @@
}
if (strcmp(fields[ZF_NAME], TZDEFAULT) == 0  lcltime != NULL) {
buf = erealloc(buf, (int) (132 + strlen(TZDEFAULT)));
-   (void) sprintf(buf,
+   (void) snprintf(buf, sizeof(buf),
 _(\Zone %s\ line and -l option are mutually exclusive),
TZDEFAULT);
error(buf);
@@ -967,7 +967,7 @@
}
if (strcmp(fields[ZF_NAME], TZDEFRULES) == 0  psxrules != NULL) {
buf = erealloc(buf, (int) (132 + strlen(TZDEFRULES)));
-   (void) sprintf(buf,
+   (void) snprintf(buf, sizeof(buf),
 _(\Zone %s\ line and -p option are mutually exclusive),
TZDEFRULES);
error(buf);
@@ -979,7 +979,7 @@
buf = erealloc(buf, (int) (132 +
strlen(fields[ZF_NAME]) +
strlen(zones[i].z_filename)));
-   (void) sprintf(buf,
+   (void) snprintf(buf, sizeof(buf),
 _(duplicate zone name %s (file \%s\, line %d)),
fields[ZF_NAME],
zones[i].z_filename,
@@ -1451,7 +1451,7 @@
}
fullname = erealloc(fullname,
(int) (strlen(directory) + 1 + strlen(name) + 1));
-   (void) sprintf(fullname, %s/%s, directory, name);
+   (void) snprintf(fullname, sizeof(fullname), %s/%s, directory, name);
 
/*
 * Remove old file, if any, to snap links.
@@ -1546,7 +1546,7 @@
if (strchr(format, '/') == NULL) {
if (letters == NULL)
(void) strcpy(abbr, format);
-   else(void) sprintf(abbr, format, letters);
+   else(void) snprintf(abbr, sizeof(abbr), format, letters);
} else if (isdst)
(void) strcpy(abbr, strchr(format, '/') + 1);
else {
@@ -1887,7 +1887,7 @@
if (type == NULL || *type == '\0')
return TRUE;
buf = erealloc(buf, (int) (132 + strlen(yitcommand) + strlen(type)));
-   (void) sprintf(buf, %s %d %s, yitcommand, year, type);
+   (void) snprintf(buf, sizeof(buf), %s %d %s, yitcommand, year, type);
result = system(buf);
if (WIFEXITED(result)) switch (WEXITSTATUS(result)) {
case 0:
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]

Re: Regression tests for usr.sbin/zic and lib/libc/stdtime

2008-04-02 Thread Andrew Pantyukhin
On Wed, Apr 02, 2008 at 09:57:46AM -0400, Steven Kreuzer wrote:
 - (void) sprintf(fullname, %s/%s, directory, name);
 + (void) snprintf(fullname, sizeof(filename), %s/%s, directory, name);
 
Has a typo crawled in?
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]