Date: Wed, 2 Jun 2004 15:52:00 -0400 (EDT) From: Matthew George <mdg@secureworks.net> To: FreeBSD-gnats-submit@FreeBSD.org Subject: bin/67501: [PATCH] from Darwin: libc/net/nsap_addr.c buffer allocation Message-ID: <20040602153253.B1067@localhost> Resent-Message-ID: <200406022000.i52K0jik079957@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 67501 >Category: bin >Synopsis: [PATCH] from Darwin: libc/net/nsap_addr.c buffer allocation >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Wed Jun 02 13:00:45 PDT 2004 >Closed-Date: >Last-Modified: >Originator: Matthew George >Release: FreeBSD 5.2-CURRENT i386 >Organization: SecureWorks >Environment: System: FreeBSD mdg.secureworks.net 5.2-CURRENT FreeBSD 5.2-CURRENT #2: Mon Mar 29 12:02:58 EST 2004 mdg@mdg.secureworks.net:/usr/obj/usr/src/sys/GENERIC i386 >Description: this changes the function inet_nsap_ntoa() such that it will dynamically allocate (and verify the allocation of) its temporary buffer, a pointer to which is returned to the caller. NULL is returned if malloc() fails. This was taken from the Darwin libc package, in the net/FreeBSD directory. The original BSD license has been retained. >How-To-Repeat: >Fix: Index: lib/libc/net/nsap_addr.c =================================================================== RCS file: /home/ncvs/src/lib/libc/net/nsap_addr.c,v retrieving revision 1.9 diff -u -r1.9 nsap_addr.c --- lib/libc/net/nsap_addr.c 22 Mar 2002 21:52:29 -0000 1.9 +++ lib/libc/net/nsap_addr.c 2 Jun 2004 19:32:09 -0000 @@ -26,6 +26,7 @@ #include <arpa/nameser.h> #include <ctype.h> #include <resolv.h> +#include <stdlib.h> static char xtob(c) @@ -78,9 +79,14 @@ { int nib; int i; - static char tmpbuf[255*3]; + static char *tmpbuf = NULL; char *start; + if (tmpbuf == NULL) { + tmpbuf = malloc(255*3); + if (tmpbuf == NULL) + return NULL; + } if (ascii) start = ascii; else { -- Matthew George SecureWorks Technical Operations >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040602153253.B1067>