diff options
author | jamie <jamie@FreeBSD.org> | 2010-07-15 19:21:33 +0000 |
---|---|---|
committer | jamie <jamie@FreeBSD.org> | 2010-07-15 19:21:33 +0000 |
commit | b539225cf9b1e6edf429b109c845eb3604398843 (patch) | |
tree | f8d52a7e2207968fb3c399e6c25ddda89aa8f4e2 /lib/libjail | |
parent | 9afbdfdebb2e3504b17903f4a91a22ca22280c25 (diff) | |
download | FreeBSD-src-b539225cf9b1e6edf429b109c845eb3604398843.zip FreeBSD-src-b539225cf9b1e6edf429b109c845eb3604398843.tar.gz |
Don't copy and return a potentially unset buffer when jail_get fails.
Diffstat (limited to 'lib/libjail')
-rw-r--r-- | lib/libjail/jail_getid.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/libjail/jail_getid.c b/lib/libjail/jail_getid.c index e7601d5..fa10424 100644 --- a/lib/libjail/jail_getid.c +++ b/lib/libjail/jail_getid.c @@ -94,11 +94,15 @@ jail_getname(int jid) jiov[5].iov_len = JAIL_ERRMSGLEN; jail_errmsg[0] = 0; jid = jail_get(jiov, 6, 0); - if (jid < 0 && !jail_errmsg[0]) - snprintf(jail_errmsg, JAIL_ERRMSGLEN, "jail_get: %s", - strerror(errno)); - name = strdup(namebuf); - if (name == NULL) - strerror_r(errno, jail_errmsg, JAIL_ERRMSGLEN); + if (jid < 0) { + if (!jail_errmsg[0]) + snprintf(jail_errmsg, JAIL_ERRMSGLEN, "jail_get: %s", + strerror(errno)); + return NULL; + } else { + name = strdup(namebuf); + if (name == NULL) + strerror_r(errno, jail_errmsg, JAIL_ERRMSGLEN); + } return name; } |