From patchwork Tue May 8 04:41:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 10385331 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id ABAAF60353 for ; Tue, 8 May 2018 04:43:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9D1ED28CA9 for ; Tue, 8 May 2018 04:43:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9234628CC0; Tue, 8 May 2018 04:43:42 +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=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY 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 3951528CA9 for ; Tue, 8 May 2018 04:43:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752618AbeEHEnk (ORCPT ); Tue, 8 May 2018 00:43:40 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:52078 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752644AbeEHEnc (ORCPT ); Tue, 8 May 2018 00:43:32 -0400 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w484f9PP034742 for ; Tue, 8 May 2018 04:43:31 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2017-10-26; bh=oXIPLygrU5i/wjF6GokIjNzqUhc8FTIM+iXciU/pMtU=; b=APo8xX9Re5MQktdTv5mqT44jhfsFvtDFusvIHgIHxnWs8EAQCPyNte0wTq3IFKU7jJ8h vmaxL78EO2HUH0RyS0mLpjffMllDsO2n/EAboUdCH2VmTRUDF6XEvvGQSAzX7uPlijZ9 2Kt9Iro5F7R1Rf1YvS1fiVWO0uuJPzj315GQ3Q1ULL/2IsXXsJon1CbqTHxYmLD21EvF zm5dJLXX8V44sa7EsjXwtiAx9LW5a0iOhqmEh1U8TDeFzJFd9K1jeiEQg3RhT6/bJJOE cC5o2wMrbXddHgiVLMKY3wlHQ0a7OcikVpsgFAb9RWfNnz030yJfT4yNlHqplJpqFC+D Ig== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp2130.oracle.com with ESMTP id 2hs24sey0k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 08 May 2018 04:43:31 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w484hV0r016008 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 8 May 2018 04:43:31 GMT Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w484hVWn029386 for ; Tue, 8 May 2018 04:43:31 GMT Received: from localhost.localdomain (/72.210.40.165) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 07 May 2018 21:43:31 -0700 From: Allison Henderson To: linux-xfs@vger.kernel.org Subject: [PATCH 19/21] xfsprogs: Remove single byte array from struct parent Date: Mon, 7 May 2018 21:41:17 -0700 Message-Id: <1525754479-12177-20-git-send-email-allison.henderson@oracle.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1525754479-12177-1-git-send-email-allison.henderson@oracle.com> References: <1525754479-12177-1-git-send-email-allison.henderson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8886 signatures=668698 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=726 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1805080047 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Variable sized arrays implemented this way may cause corruptions depending on how different compilers pack the structure. Signed-off-by: Allison Henderson --- include/parent.h | 1 - io/parent.c | 9 ++++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/include/parent.h b/include/parent.h index f338f96..85cef85 100644 --- a/include/parent.h +++ b/include/parent.h @@ -22,7 +22,6 @@ typedef struct parent { __u64 p_ino; __u32 p_gen; __u16 p_reclen; - char p_name[1]; } parent_t; typedef struct parent_cursor { diff --git a/io/parent.c b/io/parent.c index 1968516..55b8b49 100644 --- a/io/parent.c +++ b/io/parent.c @@ -45,7 +45,8 @@ check_parent_entry(xfs_bstat_t *bstatp, parent_t *parent) struct stat statbuf; char *str; - sprintf(fullpath, _("%s%s"), mntpt, parent->p_name); + snprintf(fullpath, parent->p_reclen, _("%s%s"), mntpt, + ((char*)parent)+sizeof(struct parent)); sts = lstat(fullpath, &statbuf); if (sts != 0) { @@ -284,9 +285,11 @@ print_parent_entry(parent_t *parent, int fullpath) printf(_("p_gen = %u\n"), parent->p_gen); printf(_("p_reclen = %u\n"), parent->p_reclen); if (fullpath) - printf(_("p_name = \"%s%s\"\n"), mntpt, parent->p_name); + printf(_("p_name = \"%s%s\"\n"), mntpt, + ((char*)parent)+sizeof(struct parent)); else - printf(_("p_name = \"%s\"\n"), parent->p_name); + printf(_("p_name = \"%s\"\n"), + ((char*)parent)+sizeof(struct parent)); } static int