remove buffer overflow vulnerability

This commit is contained in:
randomuser 2022-09-20 16:49:14 -05:00
parent 474ac61f6e
commit 9c211f5139
1 changed files with 1 additions and 2 deletions

3
bspc.c
View File

@ -319,8 +319,7 @@ int bspwm_update(struct module *module) {
break; break;
} }
if(isdigit(module->buffer[i]) && *current == module->buffer[i]) { if(isdigit(module->buffer[i]) && *current == module->buffer[i]) {
/* XXX: susceptible to buffer overflow */ if(i <= MODULE_BUFFER_LEN - 2) module->buffer[i + 1] = '<';
if(i == MODULE_BUFFER_LEN) module->buffer[i + 1] = '<';
*current = '\0'; *current = '\0';
} }
if(module->buffer[i] == '\n') if(module->buffer[i] == '\n')