bin/67501: [PATCH] from Darwin: libc/net/nsap_addr.c buffer
allocation
Matthew George
mdg at secureworks.net
Wed Jun 2 13:00:45 PDT 2004
>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 at 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:
More information about the freebsd-bugs
mailing list