From owner-freebsd-hackers@FreeBSD.ORG Wed Apr 2 14:33:57 2008 Return-Path: Delivered-To: freebsd-hackers@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A4989106564A for ; Wed, 2 Apr 2008 14:33:57 +0000 (UTC) (envelope-from skreuzer@exit2shell.com) Received: from scruffy.exit2shell.com (64.147.114.188.static.nyinternet.net [64.147.114.188]) by mx1.freebsd.org (Postfix) with ESMTP id 5F4CA8FC14 for ; Wed, 2 Apr 2008 14:33:56 +0000 (UTC) (envelope-from skreuzer@exit2shell.com) Received: from scruffy.exit2shell.com (64.147.114.188.static.nyinternet.net [64.147.114.188]) by scruffy.exit2shell.com (8.14.1/8.14.1) with ESMTP id m32EapqK003989 for ; Wed, 2 Apr 2008 10:36:56 -0400 (EDT) (envelope-from skreuzer@scruffy.exit2shell.com) Received: (from skreuzer@localhost) by scruffy.exit2shell.com (8.14.1/8.14.1/Submit) id m32EapIU003988 for freebsd-hackers@FreeBSD.org; Wed, 2 Apr 2008 10:36:51 -0400 (EDT) (envelope-from skreuzer) Date: Wed, 2 Apr 2008 10:36:51 -0400 From: Steven Kreuzer To: freebsd-hackers@FreeBSD.org Message-ID: <20080402143651.GC2659@scruffy.exit2shell.com> References: <20080402115408.GA66944@k7.mavetju> <20080402135746.GA2659@scruffy.exit2shell.com> <20080402142723.GI4692@amilo.cenkes.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="QKdGvSO+nmPlgiQ/" Content-Disposition: inline In-Reply-To: <20080402142723.GI4692@amilo.cenkes.org> User-Agent: Mutt/1.4.2.3i Cc: Subject: Re: Regression tests for usr.sbin/zic and lib/libc/stdtime X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Apr 2008 14:33:57 -0000 --QKdGvSO+nmPlgiQ/ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 --QKdGvSO+nmPlgiQ/ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="zic_c_snprintf-update.txt" 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 -0000 1.18 +++ zic.c 26 Mar 2008 16:27:43 -0000 @@ -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: --QKdGvSO+nmPlgiQ/--