summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2014-04-18 15:12:14 -0700
committerKeith Packard <keithp@keithp.com>2014-04-18 16:30:18 -0700
commitc7011249d2abe6cc7af82ee4b79d8f6873444707 (patch)
tree6e195c2c56cd305ccbfef6b5c10e199656d596f9
parent0af8788579c2f52cc1172952c9004483bf863932 (diff)
xkb: Verify reads of compiled keymap header and TOCmaster
Check the return values from fread to make sure the elements are actually getting read from the file. Signed-off-by: Keith Packard <keithp@keithp.com> Reviewed-by: Jamey Sharp <jamey@minilop.net>
-rw-r--r--xkb/xkmread.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/xkb/xkmread.c b/xkb/xkmread.c
index 258bb91b5..b6241b5c7 100644
--- a/xkb/xkmread.c
+++ b/xkb/xkmread.c
@@ -1204,7 +1204,8 @@ XkmReadTOC(FILE * file, xkmFileInfo * file_info, int max_toc,
}
return 0;
}
- fread(file_info, SIZEOF(xkmFileInfo), 1, file);
+ if (fread(file_info, SIZEOF(xkmFileInfo), 1, file) != 1)
+ return 0;
size_toc = file_info->num_toc;
if (size_toc > max_toc) {
DebugF("Warning! Too many TOC entries; last %d ignored\n",
@@ -1212,7 +1213,8 @@ XkmReadTOC(FILE * file, xkmFileInfo * file_info, int max_toc,
size_toc = max_toc;
}
for (i = 0; i < size_toc; i++) {
- fread(&toc[i], SIZEOF(xkmSectionInfo), 1, file);
+ if (fread(&toc[i], SIZEOF(xkmSectionInfo), 1, file) != 1)
+ return 0;
}
return 1;
}