Skip to content

Commit

Permalink
first round of ASan (+ compiler warning fixes)
Browse files Browse the repository at this point in the history
  • Loading branch information
nift4 committed Aug 2, 2024
1 parent 48a2587 commit 19bd289
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 9 deletions.
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,6 @@ target_include_directories(droidboot_gui PUBLIC
droidboot_platforms/libc-hack/lk
include
.
)
)
target_compile_options(droidboot_gui PUBLIC -fsanitize=address -fsanitize-recover=address -fno-omit-frame-pointer)
target_link_options(droidboot_gui PUBLIC -fsanitize=address -fsanitize-recover=address)
2 changes: 1 addition & 1 deletion common/droidboot_stdfunc.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ static inline bool _is_digit(char ch)
}

// internal ASCII string to unsigned int conversion
unsigned int droidboot_atoi(char* str)
unsigned int droidboot_atoi(const char* str)
{
// Initialize result
int res = 0;
Expand Down
3 changes: 2 additions & 1 deletion config_parser/droidboot_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ struct global_config {
};

int config_parse_option(char **_dest, const char *option, const char *buffer) {
char *option_whitespace = malloc(strlen(option)+strlen(" "));
char *option_whitespace = malloc(strlen(option)+strlen(" ")+1);
strcpy(option_whitespace, option);
strcat(option_whitespace, " ");
char *temp = strstr(buffer, option_whitespace);
Expand Down Expand Up @@ -284,6 +284,7 @@ int parse_global_config(struct global_config *global_config) {
ext4_fread(&fp, buf, fsize, NULL);

ext4_fclose(&fp);
buf[fsize] = '\0';

ret = config_parse_option(&global_config->default_entry_title, "default", (const char *)buf);
if(ret < 0) {
Expand Down
10 changes: 5 additions & 5 deletions dualboot_gui/dualboot_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ static void event_handler(lv_event_t * e)
droidboot_log(DROIDBOOT_LOG_TRACE, "dualboot menu: got event\n");
lv_event_code_t code = lv_event_get_code(e);
lv_obj_t * obj = lv_event_get_target(e);
int index = lv_obj_get_child_id(obj);
uint32_t index = lv_obj_get_child_id(obj);
if(code == LV_EVENT_CLICKED) {
//lvgl_show_boot_logo();
// Lets firstly write index to metadata
ext4_file f;
int ret = ext4_fopen(&f, "/boot/db/last_index", "wb");

char s[128]="";
sprintf(s,"%ld", index);
sprintf(s,"%u", index);
ret=ext4_fwrite(&f, s, 128, 0);
ret=ext4_fclose(&f);

Expand Down Expand Up @@ -99,7 +99,7 @@ void timeout_handler(lv_timer_t * timer2)
ret=ext4_fclose(&fp);

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

if(!strcmp((droidboot_entry_list + index)->kernel, "null"))
{
Expand Down Expand Up @@ -128,8 +128,8 @@ void droidboot_add_dualboot_menu_buttons(lv_obj_t * list1){
strcat(title, (droidboot_entry_list + i)->title);
strcat(title, "\n");

if((droidboot_entry_list + i)->logo!="NULL"){
char logo_path[strlen((droidboot_entry_list + i)->logo)+strlen("/boot/"+3)];
if((droidboot_entry_list + i)->logo!=NULL){
char logo_path[strlen((droidboot_entry_list + i)->logo)+strlen("/boot/")+3];
strcpy(logo_path, "/boot/");
strcat(logo_path, (droidboot_entry_list + i)->logo);
list_btn = lv_list_add_btn(list1, droidboot_load_lvgl_image_from_ext4(logo_path), title);
Expand Down
2 changes: 1 addition & 1 deletion include/droidboot_stdfunc.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#pragma once
// internal ASCII string to unsigned int conversion
unsigned int droidboot_atoi(const char ** str);
unsigned int droidboot_atoi(const char * str);
long droidboot_strtol(const char *restrict nptr, char **restrict endptr, int base);

0 comments on commit 19bd289

Please sign in to comment.