0002-Replace-call-to-strncpy-by-memcpy-to-fix-some-GCC8-w.patch (3517B)
1 From 9fc8c48fa59a6d7aaa4c7df7642bfd316086d3b7 Mon Sep 17 00:00:00 2001 2 From: Elie ROUDNINSKI <xademax@gmail.com> 3 Date: Sun, 7 Oct 2018 18:38:47 +0100 4 Subject: [PATCH] Replace call to strncpy by memcpy to fix some GCC8 warnings 5 6 --- 7 src/guid.h | 30 ++++++++++++++++++++---------- 8 1 file changed, 20 insertions(+), 10 deletions(-) 9 10 diff --git a/src/guid.h b/src/guid.h 11 index d4a06f9..c03a362 100644 12 --- a/src/guid.h 13 +++ b/src/guid.h 14 @@ -103,7 +103,8 @@ text_to_guid(const char *text, efi_guid_t *guid) 15 16 /* 84be9c3e-8a32-42c0-891c-4cd3b072becc 17 * ^ */ 18 - strncpy(eightbytes, text, 8); 19 + memcpy(eightbytes, text, 8); 20 + eightbytes[8] = 0; 21 if (check_segment_sanity(eightbytes, 8) < 0) 22 return -1; 23 guid->a = (uint32_t)strtoul(eightbytes, NULL, 16); 24 @@ -111,7 +112,8 @@ text_to_guid(const char *text, efi_guid_t *guid) 25 26 /* 84be9c3e-8a32-42c0-891c-4cd3b072becc 27 * ^ */ 28 - strncpy(fourbytes, text+9, 4); 29 + memcpy(fourbytes, text+9, 4); 30 + fourbytes[4] = 0; 31 if (check_segment_sanity(fourbytes, 4) < 0) 32 return -1; 33 guid->b = (uint16_t)strtoul(fourbytes, NULL, 16); 34 @@ -119,7 +121,8 @@ text_to_guid(const char *text, efi_guid_t *guid) 35 36 /* 84be9c3e-8a32-42c0-891c-4cd3b072becc 37 * ^ */ 38 - strncpy(fourbytes, text+14, 4); 39 + memcpy(fourbytes, text+14, 4); 40 + fourbytes[4] = 0; 41 if (check_segment_sanity(fourbytes, 4) < 0) 42 return -1; 43 guid->c = (uint16_t)strtoul(fourbytes, NULL, 16); 44 @@ -127,7 +130,8 @@ text_to_guid(const char *text, efi_guid_t *guid) 45 46 /* 84be9c3e-8a32-42c0-891c-4cd3b072becc 47 * ^ */ 48 - strncpy(fourbytes, text+19, 4); 49 + memcpy(fourbytes, text+19, 4); 50 + fourbytes[4] = 0; 51 if (check_segment_sanity(fourbytes, 4) < 0) 52 return -1; 53 guid->d = (uint16_t)strtoul(fourbytes, NULL, 16); 54 @@ -135,42 +139,48 @@ text_to_guid(const char *text, efi_guid_t *guid) 55 56 /* 84be9c3e-8a32-42c0-891c-4cd3b072becc 57 * ^ */ 58 - strncpy(twobytes, text+24, 2); 59 + memcpy(twobytes, text+24, 2); 60 + twobytes[2] = 0; 61 if (check_segment_sanity(twobytes, 2) < 0) 62 return -1; 63 guid->e[0] = (uint8_t)strtoul(twobytes, NULL, 16); 64 65 /* 84be9c3e-8a32-42c0-891c-4cd3b072becc 66 * ^ */ 67 - strncpy(twobytes, text+26, 2); 68 + memcpy(twobytes, text+26, 2); 69 + twobytes[2] = 0; 70 if (check_segment_sanity(twobytes, 2) < 0) 71 return -1; 72 guid->e[1] = (uint8_t)strtoul(twobytes, NULL, 16); 73 74 /* 84be9c3e-8a32-42c0-891c-4cd3b072becc 75 * ^ */ 76 - strncpy(twobytes, text+28, 2); 77 + memcpy(twobytes, text+28, 2); 78 + twobytes[2] = 0; 79 if (check_segment_sanity(twobytes, 2) < 0) 80 return -1; 81 guid->e[2] = (uint8_t)strtoul(twobytes, NULL, 16); 82 83 /* 84be9c3e-8a32-42c0-891c-4cd3b072becc 84 * ^ */ 85 - strncpy(twobytes, text+30, 2); 86 + memcpy(twobytes, text+30, 2); 87 + twobytes[2] = 0; 88 if (check_segment_sanity(twobytes, 2) < 0) 89 return -1; 90 guid->e[3] = (uint8_t)strtoul(twobytes, NULL, 16); 91 92 /* 84be9c3e-8a32-42c0-891c-4cd3b072becc 93 * ^ */ 94 - strncpy(twobytes, text+32, 2); 95 + memcpy(twobytes, text+32, 2); 96 + twobytes[2] = 0; 97 if (check_segment_sanity(twobytes, 2) < 0) 98 return -1; 99 guid->e[4] = (uint8_t)strtoul(twobytes, NULL, 16); 100 101 /* 84be9c3e-8a32-42c0-891c-4cd3b072becc 102 * ^ */ 103 - strncpy(twobytes, text+34, 2); 104 + memcpy(twobytes, text+34, 2); 105 + twobytes[2] = 0; 106 if (check_segment_sanity(twobytes, 2) < 0) 107 return -1; 108 guid->e[5] = (uint8_t)strtoul(twobytes, NULL, 16); 109 -- 110 2.19.0 111