From owner-freebsd-current Sun May 14 18: 4:44 2000 Delivered-To: freebsd-current@freebsd.org Received: from apollo.backplane.com (apollo.backplane.com [216.240.41.2]) by hub.freebsd.org (Postfix) with ESMTP id 5DC8537B72F for ; Sun, 14 May 2000 18:04:42 -0700 (PDT) (envelope-from dillon@apollo.backplane.com) Received: (from dillon@localhost) by apollo.backplane.com (8.9.3/8.9.1) id SAA07836; Sun, 14 May 2000 18:04:30 -0700 (PDT) (envelope-from dillon) Date: Sun, 14 May 2000 18:04:30 -0700 (PDT) From: Matthew Dillon Message-Id: <200005150104.SAA07836@apollo.backplane.com> To: Assar Westerlund Cc: "Jordan K. Hubbard" , freebsd-current@FreeBSD.ORG Subject: Re: Proposed patch for PR misc/18466 References: <200005141808.LAA06752@apollo.backplane.com> <5l66sg50kz.fsf@assaris.sics.se> 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? I didn't write SAFE_STRCPY. Replacement is a good idea, but would be future work. :> - 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? Look a little down in the code, you will notice that it rewrites the buffer. asprintf only allocates what it needs, which may not be enough. (If I had written it I would have simply reallocated the buffer, but since I didn't.... this would be a future improvement to make). :> +void :> +safe_asprintf(char **pptr, const char *ctl, ...) : :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 Under normal conditions, yes, but there is not a single line of code in sysinstall which uses varargs, and it only takes 10 seconds to add a v-version so we'll leave that for another pass (perhaps a later pass to get rid of all the static buffers). -Matt Matthew Dillon To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message