menu bugfix

This commit is contained in:
tpu 2023-03-07 15:59:39 +08:00
parent abe14ea813
commit 72f8ce8d22
4 changed files with 10 additions and 6 deletions

View file

@ -447,7 +447,7 @@ void menu_status(MENU_DESC *menu, char *string)
void add_menu_item(MENU_DESC *menu, char *item)
{
strcpy(menu->items[menu->num], item);
strncpy(menu->items[menu->num], item, 64);
menu->items[menu->num][36] = 0;
menu->num += 1;
}

View file

@ -264,9 +264,11 @@ static void fill_selmenu(void)
break;
// /SAROO/ISO/xxxx/xxxx.cue
char *path = path_str + LE32(&disc_path[index]);
sprintf(tmp, "%2d: %s", index, path+11);
snprintf(tmp, 128, "%2d: %s", index, path+11);
tmp[127] = 0;
char *p = strchr(tmp, '/');
*p = 0;
if(p)
*p = 0;
add_menu_item(&sel_menu, tmp);
}

View file

@ -114,7 +114,9 @@ int sci_getc(int timeout);
extern void (*printk_putc)(int ch);
int printk(char *fmt, ...);
int sprintf(char *buf, char *fmt, ...);
int snprintf(char *buf, int size, char *fmt, ...);
#define sprintf(buf, fmt, ...) snprintf(buf, 1024, fmt, __VA_ARGS__)
int strlen(char *s);
int strcmp(char *s1, char *s2);

View file

@ -289,13 +289,13 @@ int printk(char *fmt, ...)
return printed_len;
}
int sprintf(char *buf, char *fmt, ...)
int snprintf(char *buf, int size, char *fmt, ...)
{
va_list args;
int printed_len;
va_start(args, fmt);
printed_len = vsnprintf(buf, 1024, fmt, args);
printed_len = vsnprintf(buf, size, fmt, args);
va_end(args);
return printed_len;