summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Wilgus <wilgus.william@gmail.com>2024-06-02 22:07:02 -0400
committerWilliam Wilgus <wilgus.william@gmail.com>2024-06-02 22:07:02 -0400
commit283f31dd399d839d597fa48ae98dcdccb6188fd7 (patch)
tree179259349af316f10891c0c93ad2f42a9faadf51
parentce6fbe4382ea9abfb67d1343814b6772a9a6f7ab (diff)
downloadrockbox-283f31dd39.tar.gz
rockbox-283f31dd39.zip
[coverity] language.c lang_load() check bytes read for headers
Change-Id: I546f316692c6d0c201d36d3346aab7aab6cc4919
-rw-r--r--apps/language.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/apps/language.c b/apps/language.c
index d177303d89..53b7f8aeb5 100644
--- a/apps/language.c
+++ b/apps/language.c
@@ -70,13 +70,18 @@ int lang_load(const char *filename, const unsigned char *builtin,
if(fd < 0)
return 1;
- read(fd, lang_header, HEADER_SIZE);
- if((lang_header[0] == LANGUAGE_COOKIE) &&
+
+ if(read(fd, lang_header, HEADER_SIZE) == HEADER_SIZE &&
+ ((lang_header[0] == LANGUAGE_COOKIE) &&
(lang_header[1] == LANGUAGE_VERSION) &&
- (lang_header[2] == TARGET_ID)) {
+ (lang_header[2] == TARGET_ID))) {
/* jump to the proper entry in the table of subheaders */
lseek(fd, user_num * SUBHEADER_SIZE, SEEK_CUR);
- read(fd, sub_header, SUBHEADER_SIZE);
+ if (read(fd, sub_header, SUBHEADER_SIZE) != SUBHEADER_SIZE)
+ {
+ DEBUGF("Language %s bad subheader %u\n", filename, user_num);
+ retcode = 4;
+ }
/* read in information about the requested lang */
#if 0 /* unused */
unsigned int num_strings = (sub_header[0]<<8) | sub_header[1];