summaryrefslogtreecommitdiffstats
path: root/libexec/pppoed
diff options
context:
space:
mode:
authorscf <scf@FreeBSD.org>2007-07-04 00:00:41 +0000
committerscf <scf@FreeBSD.org>2007-07-04 00:00:41 +0000
commit196b6346ba4e13a3f7679e2de3317b6aa65983df (patch)
tree423c7d016f87f6541b9ef8231a14f8b267bc5d5e /libexec/pppoed
parentaf5bbfbc7b6a610f0c44a56a7b2d81b96be9b1b5 (diff)
downloadFreeBSD-src-196b6346ba4e13a3f7679e2de3317b6aa65983df.zip
FreeBSD-src-196b6346ba4e13a3f7679e2de3317b6aa65983df.tar.gz
Significantly reduce the memory leak as noted in BUGS section for
setenv(3) by tracking the size of the memory allocated instead of using strlen() on the current value. Convert all calls to POSIX from historic BSD API: - unsetenv returns an int. - putenv takes a char * instead of const char *. - putenv no longer makes a copy of the input string. - errno is set appropriately for POSIX. Exceptions involve bad environ variable and internal initialization code. These both set errno to EFAULT. Several patches to base utilities to handle the POSIX changes from Andrey Chernov's previous commit. A few I re-wrote to use setenv() instead of putenv(). New regression module for tools/regression/environ to test these functions. It also can be used to test the performance. Bump __FreeBSD_version to 700050 due to API change. PR: kern/99826 Approved by: wes Approved by: re (kensmith)
Diffstat (limited to 'libexec/pppoed')
-rw-r--r--libexec/pppoed/pppoed.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/libexec/pppoed/pppoed.c b/libexec/pppoed/pppoed.c
index 8dfebb7..f07dd8c 100644
--- a/libexec/pppoed/pppoed.c
+++ b/libexec/pppoed/pppoed.c
@@ -258,7 +258,7 @@ Spawn(const char *prog, const char *acname, const char *provider,
struct ng_mesg *rep = (struct ng_mesg *)msgbuf;
struct ngpppoe_sts *sts = (struct ngpppoe_sts *)(msgbuf + sizeof *rep);
struct ngpppoe_init_data *data;
- char env[sizeof(HISMACADDR)+18], unknown[14], sessionid[5], *path;
+ char env[18], unknown[14], sessionid[5], *path;
unsigned char *macaddr;
const char *msg;
int ret, slen;
@@ -352,11 +352,11 @@ Spawn(const char *prog, const char *acname, const char *provider,
/* Put the peer's MAC address in the environment */
if (sz >= sizeof(struct ether_header)) {
macaddr = ((struct ether_header *)request)->ether_shost;
- snprintf(env, sizeof(env), "%s=%x:%x:%x:%x:%x:%x", HISMACADDR,
+ snprintf(env, sizeof(env), "%x:%x:%x:%x:%x:%x",
macaddr[0], macaddr[1], macaddr[2], macaddr[3], macaddr[4],
macaddr[5]);
- if (putenv(env) != 0)
- syslog(LOG_INFO, "putenv: cannot set %s: %m", env);
+ if (setenv(HISMACADDR, env, 1) != 0)
+ syslog(LOG_INFO, "setenv: cannot set %s: %m", HISMACADDR);
}
/* And send our request data to the waiting node */
OpenPOWER on IntegriCloud