Skip to content

Commit 19bd289

Browse files
committed
first round of ASan (+ compiler warning fixes)
1 parent 48a2587 commit 19bd289

File tree

5 files changed

+12
-9
lines changed

5 files changed

+12
-9
lines changed

CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,6 @@ target_include_directories(droidboot_gui PUBLIC
5858
droidboot_platforms/libc-hack/lk
5959
include
6060
.
61-
)
61+
)
62+
target_compile_options(droidboot_gui PUBLIC -fsanitize=address -fsanitize-recover=address -fno-omit-frame-pointer)
63+
target_link_options(droidboot_gui PUBLIC -fsanitize=address -fsanitize-recover=address)

common/droidboot_stdfunc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ static inline bool _is_digit(char ch)
66
}
77

88
// internal ASCII string to unsigned int conversion
9-
unsigned int droidboot_atoi(char* str)
9+
unsigned int droidboot_atoi(const char* str)
1010
{
1111
// Initialize result
1212
int res = 0;

config_parser/droidboot_config.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ struct global_config {
5050
};
5151

5252
int config_parse_option(char **_dest, const char *option, const char *buffer) {
53-
char *option_whitespace = malloc(strlen(option)+strlen(" "));
53+
char *option_whitespace = malloc(strlen(option)+strlen(" ")+1);
5454
strcpy(option_whitespace, option);
5555
strcat(option_whitespace, " ");
5656
char *temp = strstr(buffer, option_whitespace);
@@ -284,6 +284,7 @@ int parse_global_config(struct global_config *global_config) {
284284
ext4_fread(&fp, buf, fsize, NULL);
285285

286286
ext4_fclose(&fp);
287+
buf[fsize] = '\0';
287288

288289
ret = config_parse_option(&global_config->default_entry_title, "default", (const char *)buf);
289290
if(ret < 0) {

dualboot_gui/dualboot_menu.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@ static void event_handler(lv_event_t * e)
3434
droidboot_log(DROIDBOOT_LOG_TRACE, "dualboot menu: got event\n");
3535
lv_event_code_t code = lv_event_get_code(e);
3636
lv_obj_t * obj = lv_event_get_target(e);
37-
int index = lv_obj_get_child_id(obj);
37+
uint32_t index = lv_obj_get_child_id(obj);
3838
if(code == LV_EVENT_CLICKED) {
3939
//lvgl_show_boot_logo();
4040
// Lets firstly write index to metadata
4141
ext4_file f;
4242
int ret = ext4_fopen(&f, "/boot/db/last_index", "wb");
4343

4444
char s[128]="";
45-
sprintf(s,"%ld", index);
45+
sprintf(s,"%u", index);
4646
ret=ext4_fwrite(&f, s, 128, 0);
4747
ret=ext4_fclose(&f);
4848

@@ -99,7 +99,7 @@ void timeout_handler(lv_timer_t * timer2)
9999
ret=ext4_fclose(&fp);
100100

101101
droidboot_log(DROIDBOOT_LOG_INFO, "droidboot_menu: last entry is: %s\n", buf);
102-
int index = droidboot_atoi(buf);
102+
uint index = droidboot_atoi(buf);
103103

104104
if(!strcmp((droidboot_entry_list + index)->kernel, "null"))
105105
{
@@ -128,8 +128,8 @@ void droidboot_add_dualboot_menu_buttons(lv_obj_t * list1){
128128
strcat(title, (droidboot_entry_list + i)->title);
129129
strcat(title, "\n");
130130

131-
if((droidboot_entry_list + i)->logo!="NULL"){
132-
char logo_path[strlen((droidboot_entry_list + i)->logo)+strlen("/boot/"+3)];
131+
if((droidboot_entry_list + i)->logo!=NULL){
132+
char logo_path[strlen((droidboot_entry_list + i)->logo)+strlen("/boot/")+3];
133133
strcpy(logo_path, "/boot/");
134134
strcat(logo_path, (droidboot_entry_list + i)->logo);
135135
list_btn = lv_list_add_btn(list1, droidboot_load_lvgl_image_from_ext4(logo_path), title);

include/droidboot_stdfunc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#pragma once
22
// internal ASCII string to unsigned int conversion
3-
unsigned int droidboot_atoi(const char ** str);
3+
unsigned int droidboot_atoi(const char * str);
44
long droidboot_strtol(const char *restrict nptr, char **restrict endptr, int base);

0 commit comments

Comments
 (0)