Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 1 | From 85c7694a5cf34597909bdd1ca6931b0f99904c2e Mon Sep 17 00:00:00 2001 |
| 2 | From: Robert Yang <liezhi.yang@windriver.com> |
| 3 | Date: Tue, 19 Jun 2018 00:40:49 -0700 |
| 4 | Subject: [PATCH] annotate.c/gdft.c: Replace strncpy with memccpy to fix |
| 5 | -Wstringop-truncation. |
| 6 | |
| 7 | Fixed for gcc8: |
| 8 | 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] |
| 9 | |
| 10 | Upstream-Status: Submitted [https://github.com/libgd/libgd/pull/442] |
| 11 | |
| 12 | Signed-off-by: Robert Yang <liezhi.yang@windriver.com> |
| 13 | --- |
| 14 | src/annotate.c | 2 +- |
| 15 | src/gdft.c | 2 +- |
| 16 | 2 files changed, 2 insertions(+), 2 deletions(-) |
| 17 | |
| 18 | diff --git a/src/annotate.c b/src/annotate.c |
| 19 | index 00aaf49..17df813 100644 |
| 20 | --- a/src/annotate.c |
| 21 | +++ b/src/annotate.c |
| 22 | @@ -104,7 +104,7 @@ int main(int argc, char *argv[]) |
| 23 | fprintf(stderr, "Font maximum length is 1024, %d given\n", font_len); |
| 24 | goto badLine; |
| 25 | } |
| 26 | - strncpy(font, st, font_len); |
| 27 | + memcpy(font, st, font_len); |
| 28 | } |
| 29 | } else if(!strcmp(st, "align")) { |
| 30 | char *st = strtok(0, " \t\r\n"); |
| 31 | diff --git a/src/gdft.c b/src/gdft.c |
| 32 | index 9fa8295..81dbe41 100644 |
| 33 | --- a/src/gdft.c |
| 34 | +++ b/src/gdft.c |
| 35 | @@ -1696,7 +1696,7 @@ static char * font_path(char **fontpath, char *name_list) |
| 36 | gdFree(path); |
| 37 | return "could not alloc full list of fonts"; |
| 38 | } |
| 39 | - strncpy(fontlist, name_list, name_list_len); |
| 40 | + memcpy(fontlist, name_list, name_list_len); |
| 41 | fontlist[name_list_len] = 0; |
| 42 | |
| 43 | /* |
| 44 | -- |
| 45 | 2.10.2 |
| 46 | |