summaryrefslogtreecommitdiffstats
path: root/cpukit/libnetworking/nfs/bootp_subr.c
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2003-02-20 21:21:28 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2003-02-20 21:21:28 +0000
commit7ac73e6ee2af1a0bcdcccf76344e60db558efe9a (patch)
treef2e851693d4a9e0fcceea1cbe183f3e1072fd9fe /cpukit/libnetworking/nfs/bootp_subr.c
parent2003-02-20 Till Straumann <strauman@slac.stanford.edu> (diff)
downloadrtems-7ac73e6ee2af1a0bcdcccf76344e60db558efe9a.tar.bz2
2003-02-20 Till Straumann <strauman@slac.stanford.edu>
PR 351/networking * nfs/bootp_subr.c: Fix ridiculous leak in bootp and use strdup_bootp_realloc() everywhere for sake of consistency.
Diffstat (limited to '')
-rw-r--r--cpukit/libnetworking/nfs/bootp_subr.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/cpukit/libnetworking/nfs/bootp_subr.c b/cpukit/libnetworking/nfs/bootp_subr.c
index 706ab51a50..7328a21f2c 100644
--- a/cpukit/libnetworking/nfs/bootp_subr.c
+++ b/cpukit/libnetworking/nfs/bootp_subr.c
@@ -274,11 +274,13 @@ void *bootp_strdup_realloc(char *dst,const char *src)
if (dst == NULL) {
/* first allocation, simply use strdup */
- dst = strdup(src);
+ if (src)
+ dst = strdup(src);
}
else {
/* already allocated, so use realloc/strcpy */
- len = strlen(src) + 1;
+ len = src ? strlen(src) + 1 : 0;
+ /* src == NULL tells us to effectively free dst */
dst = realloc(dst,len);
if (dst != NULL) {
strcpy(dst,src);
@@ -945,7 +947,10 @@ bootpc_init(int update_files)
update_files = 0;
}
- dhcp_hostname = NULL;
+ if (dhcp_hostname != NULL) {
+ /* free it */
+ dhcp_hostname=bootp_strdup_realloc(dhcp_hostname,0);
+ }
/*
* Find a network interface.