diff mbox

Don't ignore too long lines in nss_files (BZ #17079)

Message ID mvmzjh4x7x2.fsf@hawking.suse.de
State Committed
Headers show

Commit Message

Andreas Schwab June 23, 2014, 10 a.m. UTC
This fixes a misplaced line in the patch for bug 16071 which is causing
nss_files to ignore lines that are longer than the supplied buffer,
instead of returning ERANGE to the caller.

Andreas.

	[BZ #17079]
	* nss/nss_files/files-XXX.c (get_contents): Store overflow marker
	before reading the next line.

Comments

Patchwork Bot June 23, 2014, 10:05 a.m. UTC | #1
Looks good, thanks.

Siddhesh

On 23 June 2014 15:30, Andreas Schwab <schwab@suse.de> wrote:
> This fixes a misplaced line in the patch for bug 16071 which is causing
> nss_files to ignore lines that are longer than the supplied buffer,
> instead of returning ERANGE to the caller.
>
> Andreas.
>
>         [BZ #17079]
>         * nss/nss_files/files-XXX.c (get_contents): Store overflow marker
>         before reading the next line.
>
> diff --git a/nss/nss_files/files-XXX.c b/nss/nss_files/files-XXX.c
> index 00b2ecf..212b938 100644
> --- a/nss/nss_files/files-XXX.c
> +++ b/nss/nss_files/files-XXX.c
> @@ -198,10 +198,12 @@ get_contents (char *linebuf, size_t len, FILE *stream)
>      {
>        int curlen = ((remaining_len > (size_t) INT_MAX) ? INT_MAX
>                     : remaining_len);
> -      char *p = fgets_unlocked (curbuf, curlen, stream);
>
> +      /* Terminate the line so that we can test for overflow.  */
>        ((unsigned char *) curbuf)[curlen - 1] = 0xff;
>
> +      char *p = fgets_unlocked (curbuf, curlen, stream);
> +
>        /* EOF or read error.  */
>        if (p == NULL)
>          return gcr_error;
> --
> 2.0.0
>
> --
> Andreas Schwab, SUSE Labs, schwab@suse.de
> GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
> "And now for something completely different."
diff mbox

Patch

diff --git a/nss/nss_files/files-XXX.c b/nss/nss_files/files-XXX.c
index 00b2ecf..212b938 100644
--- a/nss/nss_files/files-XXX.c
+++ b/nss/nss_files/files-XXX.c
@@ -198,10 +198,12 @@  get_contents (char *linebuf, size_t len, FILE *stream)
     {
       int curlen = ((remaining_len > (size_t) INT_MAX) ? INT_MAX
 		    : remaining_len);
-      char *p = fgets_unlocked (curbuf, curlen, stream);
 
+      /* Terminate the line so that we can test for overflow.  */
       ((unsigned char *) curbuf)[curlen - 1] = 0xff;
 
+      char *p = fgets_unlocked (curbuf, curlen, stream);
+
       /* EOF or read error.  */
       if (p == NULL)
         return gcr_error;