mirror of
https://github.com/Rockbox/rockbox.git
synced 2026-10-10 08:03:04 -04:00
FS#14019: Detect and reject outdated binary language files (WIP)
Accomplish this by checksumming the english language input and (1) including that in binary files and (2) checking the value matches what was compiled into the firmware image Not sure if this is the best approach but it works. Change-Id: I8f79ad1b9d1cdf69e6a085d7b3dd1b5e078af04b
This commit is contained in:
parent
265cf7ac92
commit
c0ae6c7cd1
3 changed files with 28 additions and 11 deletions
|
|
@ -9,11 +9,14 @@
|
|||
# Copyright (C) 2006 - 2008 by Daniel Stenberg
|
||||
#
|
||||
|
||||
use Digest::SHA1;
|
||||
|
||||
# See apps/language.c (TODO: Use common include for both)
|
||||
# Cookie and binary version for the binary lang file
|
||||
my $LANGUAGE_COOKIE = 0x1a;
|
||||
my $LANGUAGE_VERSION = 0x07;
|
||||
my $VOICE_COOKIE = 0x9a;
|
||||
my $LANGUAGE_VERSION = 0x06;
|
||||
my $VOICE_VERSION = 0x06;
|
||||
my $LANGUAGE_FLAG_RTL = 0x01;
|
||||
my $LANGUAGE_FLAG_UNITS_FIRST = 0x02;
|
||||
|
||||
|
|
@ -70,6 +73,16 @@ if (!$english) {
|
|||
print STDERR "Please specify the english lang source (with -e)!\n";
|
||||
exit;
|
||||
}
|
||||
my $english_crc;
|
||||
{
|
||||
open my $fh, "<$english" or die $!;
|
||||
binmode $fh;
|
||||
my $sha = Digest::SHA1->new;
|
||||
$sha->addfile($fh);
|
||||
$english_crc = $sha->hexdigest;
|
||||
$english_crc = substr($english_crc, 0, 2);
|
||||
close $fh;
|
||||
}
|
||||
|
||||
my $target_id = $i;
|
||||
if($binary && !$target_id) {
|
||||
|
|
@ -501,6 +514,9 @@ extern unsigned char *language_strings[];
|
|||
/* this contains the concatenation of all strings, separated by \\0 chars */
|
||||
extern const unsigned char core_language_builtin[];
|
||||
|
||||
/* this is a checksum of the english language file */
|
||||
#define ENGLISH_LANG_CHECKSUM 0x$english_crc
|
||||
|
||||
#include "${prefix}_enum.h"
|
||||
|
||||
MOO
|
||||
|
|
@ -604,13 +620,13 @@ elsif($binary || $binvoice) {
|
|||
if($binary) {
|
||||
open(OUTF, ">$binary") or die "Error: Can't create $binary";
|
||||
binmode OUTF;
|
||||
printf OUTF ("%c%c%c%c", $LANGUAGE_COOKIE, $LANGUAGE_VERSION, $target_id,
|
||||
$langoptions); # magic lang file header
|
||||
printf OUTF ("%c%c%c%c%c", $LANGUAGE_COOKIE, $LANGUAGE_VERSION, $target_id,
|
||||
$langoptions, hex($english_crc)); # magic lang file header
|
||||
}
|
||||
if($binvoice) {
|
||||
open(OUTV, ">$binvoice") or die "Error: Can't create $binary";
|
||||
binmode OUTV;
|
||||
printf OUTV ("%c%c%c%c", $VOICE_COOKIE, $LANGUAGE_VERSION, $target_id,
|
||||
printf OUTV ("%c%c%c%c", $VOICE_COOKIE, $VOICE_VERSION, $target_id,
|
||||
$langoptions); # magic lang file header
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue