void-packages/srcpkgs/efivar/patches/0002-Replace-call-to-strncpy-by-memcpy-to-fix-some-GCC8-w.patch
2018-10-07 21:24:20 -03:00

111 lines
3.4 KiB
Diff

From 9fc8c48fa59a6d7aaa4c7df7642bfd316086d3b7 Mon Sep 17 00:00:00 2001
From: Elie ROUDNINSKI <xademax@gmail.com>
Date: Sun, 7 Oct 2018 18:38:47 +0100
Subject: [PATCH] Replace call to strncpy by memcpy to fix some GCC8 warnings
---
src/guid.h | 30 ++++++++++++++++++++----------
1 file changed, 20 insertions(+), 10 deletions(-)
diff --git a/src/guid.h b/src/guid.h
index d4a06f9..c03a362 100644
--- a/src/guid.h
+++ b/src/guid.h
@@ -103,7 +103,8 @@ text_to_guid(const char *text, efi_guid_t *guid)
/* 84be9c3e-8a32-42c0-891c-4cd3b072becc
* ^ */
- strncpy(eightbytes, text, 8);
+ memcpy(eightbytes, text, 8);
+ eightbytes[8] = 0;
if (check_segment_sanity(eightbytes, 8) < 0)
return -1;
guid->a = (uint32_t)strtoul(eightbytes, NULL, 16);
@@ -111,7 +112,8 @@ text_to_guid(const char *text, efi_guid_t *guid)
/* 84be9c3e-8a32-42c0-891c-4cd3b072becc
* ^ */
- strncpy(fourbytes, text+9, 4);
+ memcpy(fourbytes, text+9, 4);
+ fourbytes[4] = 0;
if (check_segment_sanity(fourbytes, 4) < 0)
return -1;
guid->b = (uint16_t)strtoul(fourbytes, NULL, 16);
@@ -119,7 +121,8 @@ text_to_guid(const char *text, efi_guid_t *guid)
/* 84be9c3e-8a32-42c0-891c-4cd3b072becc
* ^ */
- strncpy(fourbytes, text+14, 4);
+ memcpy(fourbytes, text+14, 4);
+ fourbytes[4] = 0;
if (check_segment_sanity(fourbytes, 4) < 0)
return -1;
guid->c = (uint16_t)strtoul(fourbytes, NULL, 16);
@@ -127,7 +130,8 @@ text_to_guid(const char *text, efi_guid_t *guid)
/* 84be9c3e-8a32-42c0-891c-4cd3b072becc
* ^ */
- strncpy(fourbytes, text+19, 4);
+ memcpy(fourbytes, text+19, 4);
+ fourbytes[4] = 0;
if (check_segment_sanity(fourbytes, 4) < 0)
return -1;
guid->d = (uint16_t)strtoul(fourbytes, NULL, 16);
@@ -135,42 +139,48 @@ text_to_guid(const char *text, efi_guid_t *guid)
/* 84be9c3e-8a32-42c0-891c-4cd3b072becc
* ^ */
- strncpy(twobytes, text+24, 2);
+ memcpy(twobytes, text+24, 2);
+ twobytes[2] = 0;
if (check_segment_sanity(twobytes, 2) < 0)
return -1;
guid->e[0] = (uint8_t)strtoul(twobytes, NULL, 16);
/* 84be9c3e-8a32-42c0-891c-4cd3b072becc
* ^ */
- strncpy(twobytes, text+26, 2);
+ memcpy(twobytes, text+26, 2);
+ twobytes[2] = 0;
if (check_segment_sanity(twobytes, 2) < 0)
return -1;
guid->e[1] = (uint8_t)strtoul(twobytes, NULL, 16);
/* 84be9c3e-8a32-42c0-891c-4cd3b072becc
* ^ */
- strncpy(twobytes, text+28, 2);
+ memcpy(twobytes, text+28, 2);
+ twobytes[2] = 0;
if (check_segment_sanity(twobytes, 2) < 0)
return -1;
guid->e[2] = (uint8_t)strtoul(twobytes, NULL, 16);
/* 84be9c3e-8a32-42c0-891c-4cd3b072becc
* ^ */
- strncpy(twobytes, text+30, 2);
+ memcpy(twobytes, text+30, 2);
+ twobytes[2] = 0;
if (check_segment_sanity(twobytes, 2) < 0)
return -1;
guid->e[3] = (uint8_t)strtoul(twobytes, NULL, 16);
/* 84be9c3e-8a32-42c0-891c-4cd3b072becc
* ^ */
- strncpy(twobytes, text+32, 2);
+ memcpy(twobytes, text+32, 2);
+ twobytes[2] = 0;
if (check_segment_sanity(twobytes, 2) < 0)
return -1;
guid->e[4] = (uint8_t)strtoul(twobytes, NULL, 16);
/* 84be9c3e-8a32-42c0-891c-4cd3b072becc
* ^ */
- strncpy(twobytes, text+34, 2);
+ memcpy(twobytes, text+34, 2);
+ twobytes[2] = 0;
if (check_segment_sanity(twobytes, 2) < 0)
return -1;
guid->e[5] = (uint8_t)strtoul(twobytes, NULL, 16);
--
2.19.0