diff options
Diffstat (limited to 'utils/sbtools')
-rw-r--r-- | utils/sbtools/elftosb.c | 9 | ||||
-rw-r--r-- | utils/sbtools/sbtoelf.c | 12 |
2 files changed, 17 insertions, 4 deletions
diff --git a/utils/sbtools/elftosb.c b/utils/sbtools/elftosb.c index 1b47cb58a0..3d53fb76d5 100644 --- a/utils/sbtools/elftosb.c +++ b/utils/sbtools/elftosb.c | |||
@@ -32,6 +32,7 @@ | |||
32 | #include <ctype.h> | 32 | #include <ctype.h> |
33 | #include <time.h> | 33 | #include <time.h> |
34 | #include <stdarg.h> | 34 | #include <stdarg.h> |
35 | #include <strings.h> | ||
35 | 36 | ||
36 | #include "crypto.h" | 37 | #include "crypto.h" |
37 | #include "elf.h" | 38 | #include "elf.h" |
@@ -48,6 +49,12 @@ bool g_debug = false; | |||
48 | * Misc | 49 | * Misc |
49 | */ | 50 | */ |
50 | 51 | ||
52 | char *s_getenv(const char *name) | ||
53 | { | ||
54 | char *s = getenv(name); | ||
55 | return s ? s : ""; | ||
56 | } | ||
57 | |||
51 | void generate_random_data(void *buf, size_t sz) | 58 | void generate_random_data(void *buf, size_t sz) |
52 | { | 59 | { |
53 | static int rand_fd = -1; | 60 | static int rand_fd = -1; |
@@ -968,7 +975,7 @@ int main(int argc, const char **argv) | |||
968 | return 1; | 975 | return 1; |
969 | } | 976 | } |
970 | 977 | ||
971 | if(getenv("SB_DEBUG") != NULL && strcmp(getenv("SB_DEBUG"), "YES") == 0) | 978 | if(strcasecmp(s_getenv("SB_DEBUG"), "YES") == 0) |
972 | g_debug = true; | 979 | g_debug = true; |
973 | 980 | ||
974 | g_key_array = read_keys(argv[2], &g_nr_keys); | 981 | g_key_array = read_keys(argv[2], &g_nr_keys); |
diff --git a/utils/sbtools/sbtoelf.c b/utils/sbtools/sbtoelf.c index 52d7179f2e..854af2851e 100644 --- a/utils/sbtools/sbtoelf.c +++ b/utils/sbtools/sbtoelf.c | |||
@@ -38,6 +38,7 @@ | |||
38 | #include <string.h> | 38 | #include <string.h> |
39 | #include <ctype.h> | 39 | #include <ctype.h> |
40 | #include <time.h> | 40 | #include <time.h> |
41 | #include <strings.h> | ||
41 | 42 | ||
42 | #include "crypto.h" | 43 | #include "crypto.h" |
43 | #include "elf.h" | 44 | #include "elf.h" |
@@ -76,6 +77,12 @@ uint8_t *g_buf; /* file content */ | |||
76 | char out_prefix[PREFIX_SIZE]; | 77 | char out_prefix[PREFIX_SIZE]; |
77 | const char *key_file; | 78 | const char *key_file; |
78 | 79 | ||
80 | char *s_getenv(const char *name) | ||
81 | { | ||
82 | char *s = getenv(name); | ||
83 | return s ? s : ""; | ||
84 | } | ||
85 | |||
79 | void *xmalloc(size_t s) /* malloc helper, used in elf.c */ | 86 | void *xmalloc(size_t s) /* malloc helper, used in elf.c */ |
80 | { | 87 | { |
81 | void * r = malloc(s); | 88 | void * r = malloc(s); |
@@ -338,7 +345,7 @@ static void extract(unsigned long filesize) | |||
338 | if(sb_header->header_size * BLOCK_SIZE != sizeof(struct sb_header_t)) | 345 | if(sb_header->header_size * BLOCK_SIZE != sizeof(struct sb_header_t)) |
339 | bugp("Bad header size"); | 346 | bugp("Bad header size"); |
340 | if((sb_header->major_ver != IMAGE_MAJOR_VERSION || | 347 | if((sb_header->major_ver != IMAGE_MAJOR_VERSION || |
341 | sb_header->minor_ver != IMAGE_MINOR_VERSION) && strcmp(getenv("SB_IGNORE_VER"), "YES")) | 348 | sb_header->minor_ver != IMAGE_MINOR_VERSION) && strcasecmp(s_getenv("SB_IGNORE_VER"), "YES")) |
342 | bugp("Bad file format version"); | 349 | bugp("Bad file format version"); |
343 | if(sb_header->sec_hdr_size * BLOCK_SIZE != sizeof(struct sb_section_header_t)) | 350 | if(sb_header->sec_hdr_size * BLOCK_SIZE != sizeof(struct sb_section_header_t)) |
344 | bugp("Bad section header size"); | 351 | bugp("Bad section header size"); |
@@ -497,8 +504,7 @@ static void extract(unsigned long filesize) | |||
497 | } | 504 | } |
498 | 505 | ||
499 | /* sections */ | 506 | /* sections */ |
500 | char *raw_cmd_env = getenv("SB_RAW_CMD"); | 507 | if(strcasecmp(s_getenv("SB_RAW_CMD"), "YES") != 0) |
501 | if(raw_cmd_env == NULL || strcmp(raw_cmd_env, "YES") != 0) | ||
502 | { | 508 | { |
503 | color(BLUE); | 509 | color(BLUE); |
504 | printf("Sections\n"); | 510 | printf("Sections\n"); |