From patchwork Fri Aug 29 13:32:04 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vladimir A. Nazarenko" X-Patchwork-Id: 384232 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 9E9D5140087 for ; Fri, 29 Aug 2014 23:32:22 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id; q=dns; s= default; b=hcRbFIoPHJR06OcbcDoOrslyVulTrNiM+4LVU/OlGHWLIQ0CnjRuj 0BMNdOi6ZnIv/XnC+lzmiBXZ3zedW3tjDmQj/76d2tMXOhp4hO3Ub/Ul//fXWabF u/DT5X2RIYboVVPZnzyVruznSxfCduX/L680xwd6SEu2lEnJfa6skA= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id; s=default; bh=jwPyWYqai6FS40+o0MbJ/jFfE3s=; b=yfZQ2qgvXHhRuu92uaZIpXfqHIRj r//XQaUmkHbKPxMFWV8ZEfmQAURwOtusGcO1PWwXLDeCrKrMcq1FNi28TGwc6e4n piFRqi8U4qvif/iR334oPl38g5vn1B3riB3UrguNQC46RrqSj6sB9HwPOmkdO6WB fZdkD9rNbAR9Vx4= Received: (qmail 7705 invoked by alias); 29 Aug 2014 13:32:15 -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 7694 invoked by uid 89); 29 Aug 2014 13:32:14 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 X-HELO: forward10l.mail.yandex.net X-Yandex-Uniq: 98b3ff37-4ced-41ab-8934-0a0fc779155d Authentication-Results: smtp2o.mail.yandex.net; dkim=pass header.i=@ya.ru From: "Vladimir A. Nazarenko" To: "GNU C. Library" Cc: Ulrich Drepper , naszar Subject: [PATCH] [BZ 17273] fix incorrect mount table entry parsing in __getmntent_r() Date: Sat, 30 Aug 2014 00:32:04 +1100 Message-Id: <1409319124-31716-1-git-send-email-naszar@ya.ru> From: naszar When mount entry contains only four fields and have more then one space or tab at the and, mp.mnt_freq and mp.mnt_passno will be set to some specific values as side effect from parsing of previus mount entry. It is because sscanf(""," %d %d ", &a, &b) returns -1, but this case is unprocessed. Values of mp.mnt_freq and mp.mnt_passno stays unchanged. This patch is attempt to fix described issue by removing trailing tabs and spaces. [BZ 17273] *misc/mntent_r.c: fix incorrect mount table entry parsing --- misc/mntent_r.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/misc/mntent_r.c b/misc/mntent_r.c index e68ec8e..e0a0b9d 100644 --- a/misc/mntent_r.c +++ b/misc/mntent_r.c @@ -135,7 +135,11 @@ __getmntent_r (FILE *stream, struct mntent *mp, char *buffer, int bufsiz) end_ptr = strchr (buffer, '\n'); if (end_ptr != NULL) /* chop newline */ - *end_ptr = '\0'; + { + while (end_ptr[-1] == ' ' || end_ptr[-1] == '\t') + end_ptr--; + *end_ptr = '\0'; + } else { /* Not the whole line was read. Do it now but forget it. */