buffyboard: fix potential buffer overflow
This commit is contained in:
parent
0ee2fb83d9
commit
fb73f1af12
2 changed files with 5 additions and 2 deletions
|
|
@ -52,7 +52,7 @@ static void init_opts(bb_cli_opts *opts) {
|
|||
int fd_rotate = open("/sys/class/graphics/fbcon/rotate", O_RDONLY);
|
||||
if (fd_rotate < 0) {
|
||||
bbx_log(BBX_LOG_LEVEL_WARNING, "Can not open /sys/class/graphics/fbcon/rotate");
|
||||
goto end;
|
||||
return;
|
||||
}
|
||||
|
||||
char buffer[3];
|
||||
|
|
@ -75,6 +75,9 @@ static void init_opts(bb_cli_opts *opts) {
|
|||
case '3':
|
||||
opts->rotation = LV_DISPLAY_ROTATION_90;
|
||||
break;
|
||||
default:
|
||||
bbx_log(BBX_LOG_LEVEL_WARNING, "Unexpected value of /sys/class/graphics/fbcon/rotate");
|
||||
break;
|
||||
}
|
||||
|
||||
end:
|
||||
|
|
|
|||
|
|
@ -312,7 +312,7 @@ int main(int argc, char *argv[]) {
|
|||
lseek(fd_tty, 0, SEEK_SET);
|
||||
|
||||
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) {
|
||||
bbx_log(BBX_LOG_LEVEL_WARNING, "Can't read /sys/class/tty/tty0/active");
|
||||
continue;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue