From patchwork Mon Jun 23 10:00:09 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Schwab X-Patchwork-Id: 1658 Received: (qmail 5340 invoked by alias); 23 Jun 2014 10:00:55 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 5303 invoked by uid 89); 23 Jun 2014 10:00:51 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.9 required=5.0 tests=AWL, BAYES_00, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx2.suse.de From: Andreas Schwab To: libc-alpha@sourceware.org Subject: [PATCH] Don't ignore too long lines in nss_files (BZ #17079) X-Yow: Has everybody got HALVAH spread all over their ANKLES??... Now, it's time to ``HAVE A NAGEELA''!! Date: Mon, 23 Jun 2014 12:00:09 +0200 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 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;