From owner-svn-src-stable@FreeBSD.ORG Wed Apr 3 12:17:37 2013 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id E952D7F5; Wed, 3 Apr 2013 12:17:36 +0000 (UTC) (envelope-from des@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id CCD7BABC; Wed, 3 Apr 2013 12:17:36 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r33CHann020322; Wed, 3 Apr 2013 12:17:36 GMT (envelope-from des@svn.freebsd.org) Received: (from des@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r33CHaDm020319; Wed, 3 Apr 2013 12:17:36 GMT (envelope-from des@svn.freebsd.org) Message-Id: <201304031217.r33CHaDm020319@svn.freebsd.org> From: Dag-Erling Smørgrav Date: Wed, 3 Apr 2013 12:17:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r249050 - in stable/9/contrib/openpam: doc/man lib X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Apr 2013 12:17:37 -0000 Author: des Date: Wed Apr 3 12:17:35 2013 New Revision: 249050 URL: http://svnweb.freebsd.org/changeset/base/249050 Log: MFH (r247810): correctly parse mixed quoted / unquoted text. Modified: stable/9/contrib/openpam/doc/man/openpam_straddch.3 stable/9/contrib/openpam/lib/openpam_readline.c stable/9/contrib/openpam/lib/openpam_readword.c Directory Properties: stable/9/contrib/openpam/ (props changed) Modified: stable/9/contrib/openpam/doc/man/openpam_straddch.3 ============================================================================== --- stable/9/contrib/openpam/doc/man/openpam_straddch.3 Wed Apr 3 11:51:11 2013 (r249049) +++ stable/9/contrib/openpam/doc/man/openpam_straddch.3 Wed Apr 3 12:17:35 2013 (r249050) @@ -34,7 +34,7 @@ .\" .\" $Id$ .\" -.Dd May 26, 2012 +.Dd March 3, 2013 .Dt OPENPAM_STRADDCH 3 .Os .Sh NAME @@ -73,6 +73,21 @@ and argument point to variables used to hold the size of the buffer and the length of the string it contains, respectively. .Pp +The final argument, +.Fa ch , +is the character that should be appended to +the string. If +.Fa ch +is 0, nothing is appended, but a new buffer is +still allocated if +.Fa str +is NULL. This can be used to +.Do +bootstrap +.Dc +the +string. +.Pp If a new buffer is allocated or an existing buffer is reallocated to make room for the additional character, .Fa str @@ -91,7 +106,9 @@ If the function is successful, it increments the integer variable pointed to by .Fa len -and returns 0. +(unless +.Fa ch +was 0) and returns 0. Otherwise, it leaves the variables pointed to by .Fa str , .Fa size Modified: stable/9/contrib/openpam/lib/openpam_readline.c ============================================================================== --- stable/9/contrib/openpam/lib/openpam_readline.c Wed Apr 3 11:51:11 2013 (r249049) +++ stable/9/contrib/openpam/lib/openpam_readline.c Wed Apr 3 12:17:35 2013 (r249050) @@ -62,11 +62,9 @@ openpam_readline(FILE *f, int *lineno, s size_t len, size; int ch; - if ((line = malloc(size = MIN_LINE_LENGTH)) == NULL) { - openpam_log(PAM_LOG_ERROR, "malloc(): %m"); + line = NULL; + if (openpam_straddch(&line, &size, &len, 0) != 0) return (NULL); - } - len = 0; for (;;) { ch = fgetc(f); /* strip comment */ Modified: stable/9/contrib/openpam/lib/openpam_readword.c ============================================================================== --- stable/9/contrib/openpam/lib/openpam_readword.c Wed Apr 3 11:51:11 2013 (r249049) +++ stable/9/contrib/openpam/lib/openpam_readword.c Wed Apr 3 12:17:35 2013 (r249050) @@ -86,13 +86,8 @@ openpam_readword(FILE *f, int *lineno, s /* begin quote */ quote = ch; /* edge case: empty quoted string */ - if (word == NULL && (word = malloc(1)) == NULL) { - openpam_log(PAM_LOG_ERROR, "malloc(): %m"); - errno = ENOMEM; + if (openpam_straddch(&word, &size, &len, 0) != 0) return (NULL); - } - *word = '\0'; - size = 1; } else if (ch == quote && !escape) { /* end quote */ quote = 0;