Skip to contentSkip to conversation

libblkid: fix overflow in implicit constant conversion

PATCH In review Sami Kerola 2 participants 2 messages Dec 17, 2017 – Dec 18, 2017 Util-Linux package

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libblkid: fix overflow in implicit constant conversion

---
 libblkid/src/superblocks/bcache.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
libblkid/src/superblocks/bcache.c +2 -1
index 82c1a8008..f9273b97a 100644
@@ -10,6 +10,7 @@
 
 #include <stddef.h>
 #include <stdio.h>
+#include <stdint.h>
 
 #include "superblocks.h"
 
@@ -19,7 +20,7 @@
 #define node(i, j)         ((i)->d + (j))
 #define end(i)             node(i, le16_to_cpu((i)->keys))
 
-static const char bcache_magic[] = {
+static const uint8_t bcache_magic[] = {
 	0xc6, 0x85, 0x73, 0xf6, 0x4e, 0x1a, 0x45, 0xca,
 	0x82, 0x65, 0xf5, 0x7f, 0x48, 0xba, 0x6d, 0x81
 };
Signature · 1 line
2.15.1
maintainer
#1 lore raw

libblkid/src/superblocks/bcache.c line 26

Quoted 5 lines · Sami Kerola
libblkid/src/superblocks/bcache.c +1 -1
-static const char bcache_magic[] = {
+static const uint8_t bcache_magic[] = {
 	0xc6, 0x85, 0x73, 0xf6, 0x4e, 0x1a, 0x45, 0xca,
 	0x82, 0x65, 0xf5, 0x7f, 0x48, 0xba, 0x6d, 0x81
 };

Well, libblkid assumes magic number as a string, and it seems we do not need the variable bcache_magic[] in the code at all. So I have committed:

-#define BCACHE_SB_MAGIC bcache_magic
+#define BCACHE_SB_MAGIC "\xc6\x85\x73\xf6\x4e\x1a\x45\xca\x82\x65\xf5\x7f\x48\xba\x6d\x81"

etc.

Karel

Signature · 2 lines
 Karel Zak  <[email protected]>
 http://karelzak.blogspot.com