Browse Source

fix(skipcpio): calculate and use CPIO_MAGIC_LEN

Signed-off-by: Shreenidhi Shedi <sshedi@vmware.com>
master
Shreenidhi Shedi 3 years ago committed by Jóhann B. Guðmundsson
parent
commit
3fb8723ce0
  1. 7
      src/skipcpio/skipcpio.c

7
src/skipcpio/skipcpio.c

@ -28,6 +28,7 @@ @@ -28,6 +28,7 @@
#include <string.h>

#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 @@ @@ -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) @@ -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) @@ -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;
}

Loading…
Cancel
Save