Date: Mon, 4 Mar 2013 18:46:56 +0000 (UTC) From: Dag-Erling Smørgrav <des@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org Subject: svn commit: r247809 - in vendor/openpam/dist: doc/man lib Message-ID: <201303041846.r24Iku0u062605@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: des Date: Mon Mar 4 18:46:55 2013 New Revision: 247809 URL: http://svnweb.freebsd.org/changeset/base/247809 Log: Merge upstream r634:646: correctly parse mixed quoted / unquoted text. See http://www.openpam.org/wiki/Errata#Configurationparsing for details. Modified: vendor/openpam/dist/doc/man/openpam_straddch.3 vendor/openpam/dist/lib/openpam_readline.c vendor/openpam/dist/lib/openpam_readword.c Modified: vendor/openpam/dist/doc/man/openpam_straddch.3 ============================================================================== --- vendor/openpam/dist/doc/man/openpam_straddch.3 Mon Mar 4 18:28:24 2013 (r247808) +++ vendor/openpam/dist/doc/man/openpam_straddch.3 Mon Mar 4 18:46:55 2013 (r247809) @@ -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: vendor/openpam/dist/lib/openpam_readline.c ============================================================================== --- vendor/openpam/dist/lib/openpam_readline.c Mon Mar 4 18:28:24 2013 (r247808) +++ vendor/openpam/dist/lib/openpam_readline.c Mon Mar 4 18:46:55 2013 (r247809) @@ -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: vendor/openpam/dist/lib/openpam_readword.c ============================================================================== --- vendor/openpam/dist/lib/openpam_readword.c Mon Mar 4 18:28:24 2013 (r247808) +++ vendor/openpam/dist/lib/openpam_readword.c Mon Mar 4 18:46:55 2013 (r247809) @@ -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;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201303041846.r24Iku0u062605>