From owner-freebsd-current Sun May 14 13:38:55 2000 Delivered-To: freebsd-current@freebsd.org Received: from assaris.sics.se (assaris.sics.se [193.10.66.234]) by hub.freebsd.org (Postfix) with ESMTP id 33CD337B694 for ; Sun, 14 May 2000 13:38:50 -0700 (PDT) (envelope-from assar@assaris.sics.se) Received: (from assar@localhost) by assaris.sics.se (8.9.3/8.9.3) id WAA71551; Sun, 14 May 2000 22:38:37 +0200 (CEST) (envelope-from assar) To: Matthew Dillon Cc: "Jordan K. Hubbard" , freebsd-current@FreeBSD.ORG Subject: Re: Proposed patch for PR misc/18466 References: <200005141808.LAA06752@apollo.backplane.com> From: Assar Westerlund Date: 14 May 2000 22:38:36 +0200 In-Reply-To: Matthew Dillon's message of "Sun, 14 May 2000 11:08:05 -0700 (PDT)" Message-ID: <5l66sg50kz.fsf@assaris.sics.se> Lines: 74 User-Agent: Gnus/5.070098 (Pterodactyl Gnus v0.98) Emacs/20.6 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Matthew Dillon writes: > Index: anonFTP.c > =================================================================== > RCS file: /home/ncvs/src/release/sysinstall/anonFTP.c,v > retrieving revision 1.29 > diff -u -r1.29 anonFTP.c > --- anonFTP.c 2000/01/25 19:16:31 1.29 > +++ anonFTP.c 2000/05/14 17:44:11 > @@ -217,7 +217,7 @@ > SAFE_STRCPY(tconf.upload, FTP_UPLOAD); > SAFE_STRCPY(tconf.comment, FTP_COMMENT); > SAFE_STRCPY(tconf.homedir, FTP_HOMEDIR); why not call strlcpy instead of the SAFE_STRCPY macro that calls the sstrncpy and the strncpy? > Index: config.c > =================================================================== > RCS file: /home/ncvs/src/release/sysinstall/config.c,v > retrieving revision 1.156.2.1 > diff -u -r1.156.2.1 config.c > --- config.c 2000/03/30 08:12:02 1.156.2.1 > +++ config.c 2000/05/14 17:46:38 > @@ -373,8 +375,8 @@ > FILE *fp; > > if (!file_readable(config)) { > - char *line = malloc(21); > - sprintf(line, "USA_RESIDENT=%s\n", USAResident ? "YES" : "NO"); > + char *line = malloc(URMSIZE); > + snprintf(line, URMSIZE, "USA_RESIDENT=%s\n", USAResident ? "YES" : "NO"); > lines[0] = line; > nlines = 1; > } Why not call asprintf/safe_asprintf here? > Index: misc.c > =================================================================== > RCS file: /home/ncvs/src/release/sysinstall/misc.c,v > retrieving revision 1.40 > diff -u -r1.40 misc.c > --- misc.c 1999/11/27 14:33:07 1.40 > +++ misc.c 2000/05/14 17:55:41 > @@ -34,6 +34,7 @@ > #include "sysinstall.h" > #include > #include > +#include > #include > #include > #include > @@ -209,6 +210,17 @@ > if (!ptr) > msgFatal("Out of memory!"); > return ptr; > +} > + > +void > +safe_asprintf(char **pptr, const char *ctl, ...) > +{ > + va_list va; > + > + va_start(va, ctl); > + if (vasprintf(pptr, ctl, va) < 0) > + msgFatal("Out of memory!"); > + va_end(va); > } > /* Create a path biased from the VAR_INSTALL_ROOT variable (if not /) */ It would seem to me a good idea to make a v-version of this function, even if there's no place right now that wants to call it. /assar To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message