diff mbox series

Add a check to get_cpiohdr

Message ID 20200419193104.22351-4-sbabic@denx.de
State Accepted
Headers show
Series Add a check to get_cpiohdr | expand

Commit Message

Stefano Babic April 19, 2020, 7:31 p.m. UTC
Signed-off-by: Stefano Babic <sbabic@denx.de>
---
 core/cpio_utils.c | 3 +++
 1 file changed, 3 insertions(+)
diff mbox series

Patch

diff --git a/core/cpio_utils.c b/core/cpio_utils.c
index 51ac04c..da84057 100644
--- a/core/cpio_utils.c
+++ b/core/cpio_utils.c
@@ -34,6 +34,9 @@  int get_cpiohdr(unsigned char *buf, unsigned long *size,
 {
 	struct new_ascii_header *cpiohdr;
 
+	if (!buf)
+		return -EINVAL;
+
 	cpiohdr = (struct new_ascii_header *)buf;
 	if (strncmp(cpiohdr->c_magic, "070702", 6) != 0) {
 		ERROR("CPIO Format not recognized: magic not found");