summaryrefslogtreecommitdiff
path: root/apps
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 /apps
parentce6fbe4382ea9abfb67d1343814b6772a9a6f7ab (diff)
downloadrockbox-283f31dd399d839d597fa48ae98dcdccb6188fd7.tar.gz
rockbox-283f31dd399d839d597fa48ae98dcdccb6188fd7.zip
[coverity] language.c lang_load() check bytes read for headers
Change-Id: I546f316692c6d0c201d36d3346aab7aab6cc4919
Diffstat (limited to 'apps')
-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,
70 70
71 if(fd < 0) 71 if(fd < 0)
72 return 1; 72 return 1;
73 read(fd, lang_header, HEADER_SIZE); 73
74 if((lang_header[0] == LANGUAGE_COOKIE) && 74 if(read(fd, lang_header, HEADER_SIZE) == HEADER_SIZE &&
75 ((lang_header[0] == LANGUAGE_COOKIE) &&
75 (lang_header[1] == LANGUAGE_VERSION) && 76 (lang_header[1] == LANGUAGE_VERSION) &&
76 (lang_header[2] == TARGET_ID)) { 77 (lang_header[2] == TARGET_ID))) {
77 /* jump to the proper entry in the table of subheaders */ 78 /* jump to the proper entry in the table of subheaders */
78 lseek(fd, user_num * SUBHEADER_SIZE, SEEK_CUR); 79 lseek(fd, user_num * SUBHEADER_SIZE, SEEK_CUR);
79 read(fd, sub_header, SUBHEADER_SIZE); 80 if (read(fd, sub_header, SUBHEADER_SIZE) != SUBHEADER_SIZE)
81 {
82 DEBUGF("Language %s bad subheader %u\n", filename, user_num);
83 retcode = 4;
84 }
80 /* read in information about the requested lang */ 85 /* read in information about the requested lang */
81#if 0 /* unused */ 86#if 0 /* unused */
82 unsigned int num_strings = (sub_header[0]<<8) | sub_header[1]; 87 unsigned int num_strings = (sub_header[0]<<8) | sub_header[1];