From: Shreenidhi Shedi Date: Wed, 25 Aug 2021 09:38:40 +0000 (+0530) Subject: fix(skipcpio): calculate and use CPIO_MAGIC_LEN X-Git-Tag: 056~104 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3fb8723ce0066b4ba92f6dbfc4373a66d1f551c4;p=thirdparty%2Fdracut.git fix(skipcpio): calculate and use CPIO_MAGIC_LEN Signed-off-by: Shreenidhi Shedi --- diff --git a/src/skipcpio/skipcpio.c b/src/skipcpio/skipcpio.c index 89cc35491..13bfaf536 100644 --- a/src/skipcpio/skipcpio.c +++ b/src/skipcpio/skipcpio.c @@ -28,6 +28,7 @@ #include #define CPIO_MAGIC "070701" +#define CPIO_MAGIC_LEN (sizeof(CPIO_MAGIC) - 1) #define CPIO_END "TRAILER!!!" #define CPIO_ENDLEN (sizeof(CPIO_END) - 1) @@ -41,7 +42,7 @@ __func__, ##__VA_ARGS__) struct cpio_header { - char c_magic[6]; + char c_magic[CPIO_MAGIC_LEN]; char c_ino[8]; char c_mode[8]; char c_uid[8]; @@ -103,7 +104,7 @@ int main(int argc, char **argv) } /* check, if this is a cpio archive */ - if (memcmp(buf.cpio.h.c_magic, CPIO_MAGIC, 6)) { + if (memcmp(buf.cpio.h.c_magic, CPIO_MAGIC, CPIO_MAGIC_LEN)) { goto cat_rest; } @@ -138,7 +139,7 @@ int main(int argc, char **argv) goto end; } - if (memcmp(buf.cpio.h.c_magic, CPIO_MAGIC, 6)) { + if (memcmp(buf.cpio.h.c_magic, CPIO_MAGIC, CPIO_MAGIC_LEN)) { pr_err("Corrupt CPIO archive!\n"); goto end; }