--- ./unpackbootimg.c.orig	2022-07-12 22:50:11.666837511 +0200
+++ ./unpackbootimg.c	2022-07-12 22:51:03.806772364 +0200
@@ -191,7 +191,7 @@
     fseek(f, i, SEEK_SET);
     if(fread(&header, sizeof(header), 1, f)) {};
 
-    if(magic == BOOT_MAGIC) {
+    if(strncmp(magic, BOOT_MAGIC, BOOT_MAGIC_SIZE) == 0) {
         if((header.header_version < 3) || (header.header_version > hdr_ver_max)) {
             // boot_img_hdr_v2 in the backported header supports all boot_img_hdr versions and cross-compatible variants below 3
 
@@ -298,7 +298,7 @@
             write_string_to_file("hashtype", hash_type);
 
             total_read += sizeof(header);
-            if(debug > 1) fprintf(stderr, "read: %ld\n", sizeof(header)); // this will harmlessly always show 1660 since it uses boot_img_hdr_v2 for all < v3
+            if(debug > 1) fprintf(stderr, "read: %ld\n", (long)sizeof(header)); // this will harmlessly always show 1660 since it uses boot_img_hdr_v2 for all < v3
             total_read += read_padding(f, sizeof(header));
 
             write_buffer_to_file("kernel", f, header.kernel_size);
@@ -350,7 +350,7 @@
             write_string_to_file("header_version", hdrvertmp);
 
             total_read += sizeof(header);
-            if(debug > 1) fprintf(stderr, "read: %ld\n", sizeof(header));
+            if(debug > 1) fprintf(stderr, "read: %ld\n", (long)sizeof(header));
             total_read += read_padding(f, sizeof(header));
 
             write_buffer_to_file("kernel", f, header.kernel_size);
@@ -417,7 +417,7 @@
         write_string_to_file("dtb_offset", dtbofftmp);
 
         total_read += sizeof(header);
-        if(debug > 1) fprintf(stderr, "read: %ld\n", sizeof(header));
+        if(debug > 1) fprintf(stderr, "read: %ld\n", (long)sizeof(header));
         total_read += read_padding(f, sizeof(header));
 
         write_buffer_to_file("vendor_ramdisk", f, header.vendor_ramdisk_size);
