Merge branch 'fix_overflow' into 'master'

buffyboard: fix potential buffer overflow

See merge request postmarketOS/buffybox!61
This commit is contained in:
Johannes Marbach 2025-07-08 18:11:13 +00:00
commit b12ce978b1
2 changed files with 5 additions and 2 deletions

View file

@ -52,7 +52,7 @@ static void init_opts(bb_cli_opts *opts) {
int fd_rotate = open("/sys/class/graphics/fbcon/rotate", O_RDONLY); int fd_rotate = open("/sys/class/graphics/fbcon/rotate", O_RDONLY);
if (fd_rotate < 0) { if (fd_rotate < 0) {
bbx_log(BBX_LOG_LEVEL_WARNING, "Can not open /sys/class/graphics/fbcon/rotate"); bbx_log(BBX_LOG_LEVEL_WARNING, "Can not open /sys/class/graphics/fbcon/rotate");
goto end; return;
} }
char buffer[3]; char buffer[3];
@ -75,6 +75,9 @@ static void init_opts(bb_cli_opts *opts) {
case '3': case '3':
opts->rotation = LV_DISPLAY_ROTATION_90; opts->rotation = LV_DISPLAY_ROTATION_90;
break; break;
default:
bbx_log(BBX_LOG_LEVEL_WARNING, "Unexpected value of /sys/class/graphics/fbcon/rotate");
break;
} }
end: end:

View file

@ -312,7 +312,7 @@ int main(int argc, char *argv[]) {
lseek(fd_tty, 0, SEEK_SET); lseek(fd_tty, 0, SEEK_SET);
char buffer[8]; char buffer[8];
ssize_t size = read(fd_tty, buffer, sizeof(buffer)); ssize_t size = read(fd_tty, buffer, sizeof(buffer) - 1);
if (size <= 0) { if (size <= 0) {
bbx_log(BBX_LOG_LEVEL_WARNING, "Can't read /sys/class/tty/tty0/active"); bbx_log(BBX_LOG_LEVEL_WARNING, "Can't read /sys/class/tty/tty0/active");
continue; continue;