From: Koji Arai Date: Wed, 21 May 2008 14:30:42 +0000 (+0900) Subject: should not add signed operand to unsigned X-Git-Url: http://git.osdn.net/view?p=lha%2Folha.git;a=commitdiff_plain;h=a7f6a06018f382f4dd2172bb60bf901fd8514419 should not add signed operand to unsigned --- diff --git a/ar.c b/ar.c index e7ad621..cfb6ab3 100644 --- a/ar.c +++ b/ar.c @@ -193,7 +193,7 @@ get_header(char *buf, int *i, int size) s = 0; for (n = size-1; n >= 0; n--) { - s = (s << 8) + buf[*i + n]; /* little endian */ + s = (s << 8) + (unsigned char)buf[*i + n]; /* little endian */ } *i += size; return s; @@ -494,7 +494,7 @@ read_header_lv1(FILE *fp, char *buf, struct lzh_header *h) while (ext_headersize != 0) { char extbuf[4096]; - uchar ext_type; + uchar ext_type; int extpos = 0; h->compsize -= ext_headersize; @@ -509,7 +509,7 @@ read_header_lv1(FILE *fp, char *buf, struct lzh_header *h) h->mtime = get_header(extbuf, &extpos, 4); break; default: - break; + break; } extpos = ext_headersize - 2; ext_headersize = get_header(extbuf, &extpos, 2); diff --git a/randtest/randtest.rb b/randtest/randtest.rb index 15025df..0e1b594 100644 --- a/randtest/randtest.rb +++ b/randtest/randtest.rb @@ -7,6 +7,7 @@ begin lzh = "rand#{v}k.lzh" system("cat seq.bin rand#{v}k.bin seq.bin > #{file}") + puts "creating..." case :olha7 when :jlha5 then system("jlha a -o5 #{lzh} #{file}") when :jlha6 then system("jlha a -o6 #{lzh} #{file}") @@ -20,13 +21,17 @@ begin else raise end + puts "testing..." system("lha t #{lzh} > /dev/null") raise "error #{"%x" % $?.to_i}" if $?.to_i > 0 system("lha vvq #{lzh} >> tmp") + puts "extracting..." File.rename(file, file + ".tmp") system("olha x #{lzh}") raise "error #{"%x" % $?.to_i}" if $?.to_i > 0 + + puts "comparing..." system("cmp %s %s" % [file, file + ".tmp"]) raise if $?.to_i > 0