Return-Path: Received: from mail.windriver.com (mail.windriver.com [147.11.1.11]) by mail.openembedded.org (Postfix) with ESMTP id 5AD0176090 for ; Wed, 20 Jun 2018 07:13:08 +0000 (UTC) Received: from ALA-HCB.corp.ad.wrs.com ([147.11.189.41]) by mail.windriver.com (8.15.2/8.15.1) with ESMTPS id w5K7D8AI000965 (version=TLSv1 cipher=AES128-SHA bits=128 verify=FAIL); Wed, 20 Jun 2018 00:13:08 -0700 (PDT) Received: from [128.224.16.116] (128.224.16.116) by ALA-HCB.corp.ad.wrs.com (147.11.189.41) with Microsoft SMTP Server id 14.3.399.0; Wed, 20 Jun 2018 00:12:56 -0700 To: Khem Raj References: <20180620021342.12415-1-liezhi.yang@windriver.com> <98958e20-053c-931c-116f-5702093fa2c1@windriver.com> From: Robert Yang Message-ID: Date: Wed, 20 Jun 2018 15:12:53 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <98958e20-053c-931c-116f-5702093fa2c1@windriver.com> Cc: openembeded-devel Subject: Re: [meta-oe][PATCH] gd: Replace strncpy with memccpy to fix -Wstringop-truncation. X-BeenThere: openembedded-devel@lists.openembedded.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Using the OpenEmbedded metadata to build Distributions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Jun 2018 07:13:08 -0000 Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Hi Khem, On 06/20/2018 10:34 AM, Robert Yang wrote: > > > On 06/20/2018 10:28 AM, Khem Raj wrote: >> On Tue, Jun 19, 2018 at 7:14 PM Robert Yang wrote: >>> >>> Fixed: >>> git/src/gdft.c:1699:2: error: 'strncpy' output truncated before terminating >>> nul copying as many bytes from a string as its length >>> [-Werror=stringop-truncation] >>> >>> Signed-off-by: Robert Yang >>> --- >>>   ...gdft.c-Replace-strncpy-with-memccpy-to-fi.patch | 46 ++++++++++++++++++++++ >>>   meta-oe/recipes-support/gd/gd_2.2.5.bb             |  1 + >>>   2 files changed, 47 insertions(+) >>>   create mode 100644 >>> meta-oe/recipes-support/gd/gd/0001-annotate.c-gdft.c-Replace-strncpy-with-memccpy-to-fi.patch >>> >>> >>> diff --git >>> a/meta-oe/recipes-support/gd/gd/0001-annotate.c-gdft.c-Replace-strncpy-with-memccpy-to-fi.patch >>> b/meta-oe/recipes-support/gd/gd/0001-annotate.c-gdft.c-Replace-strncpy-with-memccpy-to-fi.patch >>> >>> new file mode 100644 >>> index 0000000..b175c44 >>> --- /dev/null >>> +++ >>> b/meta-oe/recipes-support/gd/gd/0001-annotate.c-gdft.c-Replace-strncpy-with-memccpy-to-fi.patch >>> >>> @@ -0,0 +1,46 @@ >>> +From 85c7694a5cf34597909bdd1ca6931b0f99904c2e Mon Sep 17 00:00:00 2001 >>> +From: Robert Yang >>> +Date: Tue, 19 Jun 2018 00:40:49 -0700 >>> +Subject: [PATCH] annotate.c/gdft.c: Replace strncpy with memccpy to fix >>> + -Wstringop-truncation. >>> + >>> +Fixed: >>> +git/src/gdft.c:1699:2: error: 'strncpy' output truncated before terminating >>> nul copying as many bytes from a string as its length >>> [-Werror=stringop-truncation] >>> + >>> +Upstream-Status: Pending >>> + >> >> could you also post this patch upstream and start a discussion? > > Thanks, I will do it today. I sent it to upstream and sent a V2: https://github.com/libgd/libgd/pull/442 // Robert > > // Robert > >> >> >>> +Signed-off-by: Robert Yang >>> +--- >>> + src/annotate.c | 2 +- >>> + src/gdft.c     | 2 +- >>> + 2 files changed, 2 insertions(+), 2 deletions(-) >>> + >>> +diff --git a/src/annotate.c b/src/annotate.c >>> +index 00aaf49..17df813 100644 >>> +--- a/src/annotate.c >>> ++++ b/src/annotate.c >>> +@@ -104,7 +104,7 @@ int main(int argc, char *argv[]) >>> +                                       fprintf(stderr, "Font maximum length >>> is 1024, %d given\n", font_len); >>> +                                       goto badLine; >>> +                               } >>> +-                              strncpy(font, st, font_len); >>> ++                              memcpy(font, st, font_len); >>> +                       } >>> +               } else if(!strcmp(st, "align")) { >>> +                       char *st = strtok(0, " \t\r\n"); >>> +diff --git a/src/gdft.c b/src/gdft.c >>> +index 9fa8295..81dbe41 100644 >>> +--- a/src/gdft.c >>> ++++ b/src/gdft.c >>> +@@ -1696,7 +1696,7 @@ static char * font_path(char **fontpath, char *name_list) >>> +               gdFree(path); >>> +               return "could not alloc full list of fonts"; >>> +       } >>> +-      strncpy(fontlist, name_list, name_list_len); >>> ++      memcpy(fontlist, name_list, name_list_len); >>> +       fontlist[name_list_len] = 0; >>> + >>> +       /* >>> +-- >>> +2.10.2 >>> + >>> diff --git a/meta-oe/recipes-support/gd/gd_2.2.5.bb >>> b/meta-oe/recipes-support/gd/gd_2.2.5.bb >>> index 63d9acf..62d0df0 100644 >>> --- a/meta-oe/recipes-support/gd/gd_2.2.5.bb >>> +++ b/meta-oe/recipes-support/gd/gd_2.2.5.bb >>> @@ -14,6 +14,7 @@ LIC_FILES_CHKSUM = >>> "file://COPYING;md5=07384b3aa2e0d39afca0d6c40286f545" >>>   DEPENDS = "freetype libpng jpeg zlib tiff" >>> >>>   SRC_URI = "git://github.com/libgd/libgd.git;branch=GD-2.2 \ >>> + >>> file://0001-annotate.c-gdft.c-Replace-strncpy-with-memccpy-to-fi.patch \ >>>             " >>> >>>   SRCREV = "8255231b68889597d04d451a72438ab92a405aba" >>> -- >>> 2.10.2 >>> >>> -- >>> _______________________________________________ >>> Openembedded-devel mailing list >>> Openembedded-devel@lists.openembedded.org >>> http://lists.openembedded.org/mailman/listinfo/openembedded-devel >>