diff options
author | Barry Wardell <rockbox@barrywardell.net> | 2007-03-22 15:53:37 +0000 |
---|---|---|
committer | Barry Wardell <rockbox@barrywardell.net> | 2007-03-22 15:53:37 +0000 |
commit | 149a7bab5bcd835a7370c3ae19a6d193a0d92e84 (patch) | |
tree | 5bc5d485ab5af86ce0a876f962ee8c9bc4874dc2 /tools/gigabeat.c | |
parent | e5b77b1a47fb99c616f3ba9045d79120fd491fab (diff) |
Make Gigabeat's scramble endian-safe.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12892 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'tools/gigabeat.c')
-rw-r--r-- | tools/gigabeat.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/tools/gigabeat.c b/tools/gigabeat.c index 863d0741f2..f4d64ea511 100644 --- a/tools/gigabeat.c +++ b/tools/gigabeat.c @@ -49,6 +49,7 @@ int gigabeat_code(char *infile, char *outfile) FILE *in, *out; unsigned long size = 0; unsigned long bytes_read; + unsigned char buf[4]; unsigned long data; unsigned long key = 0x19751217; @@ -56,8 +57,11 @@ int gigabeat_code(char *infile, char *outfile) out = openoutfile(outfile); while (!feof(in)) { - bytes_read = fread(&data, 1, 4, in); + bytes_read = fread(buf, 1, 4, in); + /* Read in little-endian */ + data = le2int(buf); + data = data ^ key; key = key + (key << 1); @@ -65,7 +69,10 @@ int gigabeat_code(char *infile, char *outfile) size += bytes_read; - fwrite(&data, 1, bytes_read, out); + /* Write out little-endian */ + int2le(data, buf); + + fwrite(buf, 1, bytes_read, out); } fprintf(stderr, "File processed successfully\n" ); |