From patchwork Wed Oct 24 11:00:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Q2zDqW1lbnQgUMOpcm9u?= X-Patchwork-Id: 10654531 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3105E14BD for ; Wed, 24 Oct 2018 11:00:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 20E0A2A51C for ; Wed, 24 Oct 2018 11:00:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 14AF62A5E2; Wed, 24 Oct 2018 11:00:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BC7952A51C for ; Wed, 24 Oct 2018 11:00:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727314AbeJXT2g (ORCPT ); Wed, 24 Oct 2018 15:28:36 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:41460 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727204AbeJXT2g (ORCPT ); Wed, 24 Oct 2018 15:28:36 -0400 Received: by mail-wr1-f65.google.com with SMTP id q7-v6so5080352wrr.8 for ; Wed, 24 Oct 2018 04:00:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=tIHlGPgDyddBEWtmgSHVqn9+naMOOYLC+w0Xgy/DFc8=; b=JnK9VJyDWrgdSikj+IF1zNn4ymwLnrTvovJTNoeSuc/WbXaPaehINB+NESfO8RoI/Q DrGoLeU+24j9ONhrVcv0uurLfzezK/Cla0MV5+KUO22oAmvKxxuoyqw6g7OOX+S1G8/+ PRTgUQaczdBdGIL3NdABPiKiwZimC5L/26M0Shzo73MJqsQgUwShSV8pCMjDmi9ba6Ai 6sc/bYy+1Rdbn/IPJ3qdrAsL8i/wM5yr0Ql7lABXuhm3B+4CI25nOZmYDJ+ffxnoJdmI n+GU2Lc0H6z6sfpKluNE8z6b5Mgyj1sCyn3eX6iJhpbcyxlufUhot3/ghTlr72QLY1N5 r1uQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=tIHlGPgDyddBEWtmgSHVqn9+naMOOYLC+w0Xgy/DFc8=; b=fs28QqB53ZKBjalAdVPPocynqDU+plxyQ9fsmG47SLtXf8Vd6xzTg0fRm0/IEnSfjA vZokBEVwxYsHdvFsaokzhQogXGtBdYA/VG1p1rPA6cFN77N+3PD1id+N5+kDkm13NSvV oyVPBhjom2/sUF0ThgBRbz+9g17zgJLEFjfJlZ6iifnpdLLtcaqq+l7OrJyjDXCwc2F7 mww9sOA1iIX0+DaJo/pleX41qTbc13k9LpJIb0/KxrVNpdXFbaifWrZsTNVsKIHYCCVu u3J9EK+OwYJel1gI0knod0VJqJ3hX8RPlr6jmLUi8W2f+iyz5MGhua8WeAyMlMi84Q7i NrAw== X-Gm-Message-State: AGRZ1gKEYIcUsbLoxcEFyal7YaC7sbRFViARpyoOBInGVrzLSvUwmyOJ eGbnyefdD+ODhxGL8tXjQ3M= X-Google-Smtp-Source: AJdET5ex46kvaNnNGHWO8L5LavRH43RU/n/7AhJhW2Wy4eo+zIMlWK9hhTuXm+HSLMVGFmPvDQTGvQ== X-Received: by 2002:adf:8141:: with SMTP id 59-v6mr2197776wrm.127.1540378856365; Wed, 24 Oct 2018 04:00:56 -0700 (PDT) Received: from cperon-Latitude-7490.event.pylonone.net ([185.7.230.213]) by smtp.gmail.com with ESMTPSA id t194-v6sm6209850wmd.48.2018.10.24.04.00.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Oct 2018 04:00:55 -0700 (PDT) From: =?utf-8?b?Q2zDqW1lbnQgUMOpcm9u?= To: Chris Ball , Ulf Hansson , Avri Altman , linux-mmc@vger.kernel.org Cc: =?utf-8?b?Q2zDqW1lbnQgUMOpcm9u?= Subject: [PATCH v2] mmc-utils: fix overlapping with strncpy Date: Wed, 24 Oct 2018 13:00:47 +0200 Message-Id: <20181024110047.17274-1-peron.clem@gmail.com> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP GCC 8.2 warns about an overlapping using strncpy. Replace strncpy with a memmove to avoid this issue. In file included from /usr/include/string.h:494, from lsmmc.c:46: In function ‘strncpy’, inlined from ‘read_file’ at lsmmc.c:356:3: /usr/include/x86_64-linux-gnu/bits/string_fortified.h:106:10: error: ‘__builtin_strncpy’ accessing 4096 bytes at offsets 0 and 1 overlaps 4095 bytes at offset 1 [-Werror=restrict] return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest)); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors make: *** [Makefile:36: lsmmc.o] Error 1 Signed-off-by: Clément Péron Acked-by: Hans-Christian Noren Egtvedt --- v2: repost with Chris Ball lsmmc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lsmmc.c b/lsmmc.c index c4faa00..bcb854d 100644 --- a/lsmmc.c +++ b/lsmmc.c @@ -353,7 +353,7 @@ char *read_file(char *name) line[strlen(line) - 1] = '\0'; while (isspace(line[0])) - strncpy(&line[0], &line[1], sizeof(line)); + memmove(&line[0], &line[1], sizeof(line)-1); return strdup(line); }