OSDN Git Service

fix iconv conversions for iso88592-iso885916
authorBartosz Brachaczek <b.brachaczek@gmail.com>
Thu, 15 Jun 2017 21:30:48 +0000 (23:30 +0200)
committerRich Felker <dalias@aerifal.cx>
Wed, 21 Jun 2017 00:41:23 +0000 (20:41 -0400)
commit 97bd6b09dbe7478d5a90a06ecd9e5b59389d8eb9 refactored the table
lookup into a function and introduced an error in index computation.
the error caused garbage to be read from the table if the given charmap
had a non-zero number of elided entries.

src/locale/iconv.c

index 4636307..fd2f2e0 100644 (file)
@@ -153,7 +153,7 @@ static void put_32(unsigned char *s, unsigned c, int e)
 
 static unsigned legacy_map(const unsigned char *map, unsigned c)
 {
-       unsigned x = c - 128 + map[-1];
+       unsigned x = c - 128 - map[-1];
        x = legacy_chars[ map[x*5/4]>>2*x%8 |
                map[x*5/4+1]<<8-2*x%8 & 1023 ];
        return x ? x : c;