From owner-p4-projects@FreeBSD.ORG Fri Jun 5 15:54:32 2009 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 26FF41065673; Fri, 5 Jun 2009 15:54:32 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DB8A7106566C for ; Fri, 5 Jun 2009 15:54:31 +0000 (UTC) (envelope-from sson@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id AFBEB8FC17 for ; Fri, 5 Jun 2009 15:54:31 +0000 (UTC) (envelope-from sson@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id n55FsVSU011722 for ; Fri, 5 Jun 2009 15:54:31 GMT (envelope-from sson@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id n55FsVkG011720 for perforce@freebsd.org; Fri, 5 Jun 2009 15:54:31 GMT (envelope-from sson@FreeBSD.org) Date: Fri, 5 Jun 2009 15:54:31 GMT Message-Id: <200906051554.n55FsVkG011720@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to sson@FreeBSD.org using -f From: Stacey Son To: Perforce Change Reviews Cc: Subject: PERFORCE change 163575 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Jun 2009 15:54:33 -0000 http://perforce.freebsd.org/chv.cgi?CH=163575 Change 163575 by sson@sson_amd64 on 2009/06/05 15:54:10 Fix parsing bug for AUT_SOCKUNIX tokens. fetch_sock_unix_tok() assumes that the path component of AUT_SOCKUNIX is a fixed length when is actually a variable length. Affected files ... .. //depot/projects/trustedbsd/openbsm/libbsm/bsm_io.c#63 edit .. //depot/projects/trustedbsd/openbsm/libbsm/bsm_token.c#93 edit Differences ... ==== //depot/projects/trustedbsd/openbsm/libbsm/bsm_io.c#63 (text+ko) ==== @@ -32,7 +32,7 @@ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - * $P4: //depot/projects/trustedbsd/openbsm/libbsm/bsm_io.c#62 $ + * $P4: //depot/projects/trustedbsd/openbsm/libbsm/bsm_io.c#63 $ */ #include @@ -3176,19 +3176,25 @@ /* * socket family 2 bytes - * path 104 bytes + * path (up to) 104 bytes + NULL (NULL terminated string). */ static int fetch_sock_unix_tok(tokenstr_t *tok, u_char *buf, int len) { int err = 0; + u_char *p; + int slen; + READ_TOKEN_U_INT16(buf, len, tok->tt.sockunix.family, tok->len, err); if (err) return (-1); - READ_TOKEN_BYTES(buf, len, tok->tt.sockunix.path, 104, tok->len, - err); + /* slen = strnlen((buf + tok->len), 104) + 1; */ + p = (u_char *)memchr((const void *)(buf + tok->len), '\0', 104); + slen = (p ? (int)(p - (buf + tok->len)) : 104) + 1; + + READ_TOKEN_BYTES(buf, len, tok->tt.sockunix.path, slen, tok->len, err); if (err) return (-1); ==== //depot/projects/trustedbsd/openbsm/libbsm/bsm_token.c#93 (text+ko) ==== @@ -30,7 +30,7 @@ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - * $P4: //depot/projects/trustedbsd/openbsm/libbsm/bsm_token.c#92 $ + * $P4: //depot/projects/trustedbsd/openbsm/libbsm/bsm_token.c#93 $ */ #include @@ -996,7 +996,7 @@ /* * token ID 1 byte * socket family 2 bytes - * path 104 bytes + * path (up to) 104 bytes + NULL (NULL terminated string) */ token_t * au_to_sock_unix(struct sockaddr_un *so)