1
0
mirror of https://github.com/anestisb/android-unpackbootimg.git synced 2024-05-16 03:59:33 +00:00

Merge pull request #3 from ValdikSS/fixes

A set of fixes
This commit is contained in:
Anestis Bechtsoudis 2023-04-05 14:49:24 +04:00 committed by GitHub
commit 813a5e9a5a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 2 deletions

View File

@ -4,7 +4,7 @@ DEP_CC ?= gcc
AR ?= ar
RANLIB ?= ranlib
STRIP ?= strip
CFLAGS += -O2 -Wall -Werror -Wno-address-of-packed-member
CFLAGS += -O2 -Wall -Werror -Wno-error=maybe-uninitialized -Wno-error=address-of-packed-member
LDFLAGS +=
# libmincrypt

View File

@ -31,12 +31,22 @@ int read_padding(FILE* f, unsigned itemsize, int pagesize)
return count;
}
void write_string_to_file(const char* file, const char* string)
int write_string_to_file(const char* file, const char* string)
{
// Try to create a directory first.
char* fcopy = strdup(file);
mkdir(dirname(fcopy), 0777);
free(fcopy);
FILE* f = fopen(file, "w");
if (!f) {
printf("File %s can't be opened.\n", file);
return 1;
}
fwrite(string, strlen(string), 1, f);
fwrite("\n", 1, 1, f);
fclose(f);
return 0;
}
const char *detect_hash_type(const struct boot_img_hdr *hdr)
@ -100,6 +110,10 @@ int main(int argc, char** argv)
int total_read = 0;
FILE* f = fopen(filename, "rb");
if (!f) {
printf("Input file not found.\n");
return 1;
}
boot_img_hdr header;
//printf("Reading header...\n");