From patchwork Sun Mar 8 03:31:34 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 5961131 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: X-Original-To: patchwork-dm-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id F28FC9F373 for ; Sun, 8 Mar 2015 04:39:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0E90B20251 for ; Sun, 8 Mar 2015 04:39:42 +0000 (UTC) Received: from mx6-phx2.redhat.com (mx6-phx2.redhat.com [209.132.183.39]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8B2302025B for ; Sun, 8 Mar 2015 04:39:39 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx6-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t284ZRmq008728; Sat, 7 Mar 2015 23:35:28 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id t284ZQ1L009347 for ; Sat, 7 Mar 2015 23:35:26 -0500 Received: from redhat.com (ask-08.lab.msp.redhat.com [10.15.85.8]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id t284ZPGb013271; Sat, 7 Mar 2015 23:35:25 -0500 Received: by redhat.com (sSMTP sendmail emulation); Sat, 07 Mar 2015 21:31:52 -0600 From: "Benjamin Marzinski" To: device-mapper development Date: Sat, 7 Mar 2015 21:31:34 -0600 Message-Id: <1425785506-20419-4-git-send-email-bmarzins@redhat.com> In-Reply-To: <1425785506-20419-1-git-send-email-bmarzins@redhat.com> References: <1425785506-20419-1-git-send-email-bmarzins@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-loop: dm-devel@redhat.com Cc: Christophe Varoqui Subject: [dm-devel] [PATCH 03/15] Revert "libmultipath: fixup strlcpy" X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk Reply-To: device-mapper development List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This reverts commit 3a64d6491a1e83adcaf5f97edd18b7898dce241d. strlcpy already had a check to make sure that as long as the size passed in wasn't zero, it would leave enough space to write the final null. So, the only check that was necessary was to see if strlcpy was called with size = 0. strlcpy returns the number of bytes that it took, or would take, to write the entire string. There is no reason why bytes would usually end up equalling size, so this commit caused strlcpy to stop null terminating many strings. Cc: "Hannes Reinecke " Signed-off-by: Benjamin Marzinski --- libmultipath/util.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libmultipath/util.c b/libmultipath/util.c index b8487ac..ac0d1b2 100644 --- a/libmultipath/util.c +++ b/libmultipath/util.c @@ -112,7 +112,8 @@ size_t strlcpy(char *dst, const char *src, size_t size) bytes++; } - if (bytes == size) + /* If size == 0 there is no space for a final null... */ + if (size) *q = '\0'; return bytes; }