mirror of
https://github.com/gryf/wmaker.git
synced 2026-02-15 13:35:53 +01:00
util: add check for size validity (Coverity #50224)
As pointed by Coverity, when reading the size of data using 'readmsg' that size cannot be fully trusted (possibly in case of bugs in present case), so this patch adds a check to ensure it is valid before continuing. Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
This commit is contained in:
committed by
Carlos R. Mafra
parent
8e9c06627d
commit
d90c8d5370
@@ -918,6 +918,14 @@ static noreturn void helperLoop(RContext * rc)
|
|||||||
memcpy(buf, buffer, 4);
|
memcpy(buf, buffer, 4);
|
||||||
buf[4] = 0;
|
buf[4] = 0;
|
||||||
size = atoi(buf);
|
size = atoi(buf);
|
||||||
|
if (size < 0 || size > sizeof(buffer)) {
|
||||||
|
wfatal("received invalid size %d for message from WindowMaker", size);
|
||||||
|
quit(1);
|
||||||
|
}
|
||||||
|
if (size == 0) {
|
||||||
|
werror("received 0-sized message from WindowMaker, trying to continue");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
/* get message */
|
/* get message */
|
||||||
if (readmsg(0, buffer, size) < 0) {
|
if (readmsg(0, buffer, size) < 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user