Date: Thu, 15 Jul 2010 19:21:33 +0000 (UTC) From: Jamie Gritton <jamie@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r210134 - head/lib/libjail Message-ID: <201007151921.o6FJLX3H077974@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jamie Date: Thu Jul 15 19:21:33 2010 New Revision: 210134 URL: http://svn.freebsd.org/changeset/base/210134 Log: Don't copy and return a potentially unset buffer when jail_get fails. Modified: head/lib/libjail/jail_getid.c Modified: head/lib/libjail/jail_getid.c ============================================================================== --- head/lib/libjail/jail_getid.c Thu Jul 15 19:21:07 2010 (r210133) +++ head/lib/libjail/jail_getid.c Thu Jul 15 19:21:33 2010 (r210134) @@ -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; }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201007151921.o6FJLX3H077974>