summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/language.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/apps/language.c b/apps/language.c
index 73ed0fe39b..bba1359616 100644
--- a/apps/language.c
+++ b/apps/language.c
@@ -31,10 +31,12 @@
31 language! */ 31 language! */
32#include "max_language_size.h" 32#include "max_language_size.h"
33 33
34/* both these must match the two initial bytes in the binary lang file */ 34/* These defines must match the initial bytes in the binary lang file */
35#define LANGUAGE_COOKIE 0x1a 35/* See tools/genlang (TODO: Use common include for both) */
36#define LANGUAGE_VERSION 0x04 36#define LANGUAGE_COOKIE 0x1a
37#define LANGUAGE_VERSION 0x04
37 38
39#define HEADER_SIZE 3
38 40
39static unsigned char language_buffer[MAX_LANGUAGE_SIZE]; 41static unsigned char language_buffer[MAX_LANGUAGE_SIZE];
40 42
@@ -54,12 +56,12 @@ int lang_load(const char *filename)
54 int fsize; 56 int fsize;
55 int fd = open(filename, O_RDONLY); 57 int fd = open(filename, O_RDONLY);
56 int retcode=0; 58 int retcode=0;
57 unsigned char lang_header[3]; 59 unsigned char lang_header[HEADER_SIZE];
58 if(fd < 0) 60 if(fd < 0)
59 return 1; 61 return 1;
60 fsize = filesize(fd) - 2; 62 fsize = filesize(fd) - HEADER_SIZE;
61 if(fsize <= MAX_LANGUAGE_SIZE) { 63 if(fsize <= MAX_LANGUAGE_SIZE) {
62 read(fd, lang_header, 3); 64 read(fd, lang_header, HEADER_SIZE);
63 if((lang_header[0] == LANGUAGE_COOKIE) && 65 if((lang_header[0] == LANGUAGE_COOKIE) &&
64 (lang_header[1] == LANGUAGE_VERSION) && 66 (lang_header[1] == LANGUAGE_VERSION) &&
65 (lang_header[2] == TARGET_ID)) { 67 (lang_header[2] == TARGET_ID)) {