]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
ext2fs: fix potential null dereference in utf8nlookup
authorGabriel Krisman Bertazi <krisman@collabora.com>
Sun, 28 Apr 2019 19:10:21 +0000 (15:10 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Sun, 28 Apr 2019 19:10:50 +0000 (15:10 -0400)
Delay the access of data->offset until after the null check.  This was
reported by 0-day on the kernel version of the script.

Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
lib/ext2fs/nls_utf8-norm.c

index 5a91573f766f16788544522afae30111d393d2c4..98c67000b0eb91bdd27cd1ab5d0a3db43efcb5ce 100644 (file)
@@ -335,7 +335,7 @@ utf8hangul(const char *str, unsigned char *hangul)
 static utf8leaf_t *utf8nlookup(const struct utf8data *data,
                               unsigned char *hangul, const char *s, size_t len)
 {
-       utf8trie_t      *trie = utf8data + data->offset;
+       utf8trie_t      *trie;
        int             offlen;
        int             offset;
        int             mask;
@@ -345,6 +345,8 @@ static utf8leaf_t *utf8nlookup(const struct utf8data *data,
                return NULL;
        if (len == 0)
                return NULL;
+
+       trie = utf8data + data->offset;
        node = 1;
        while (node) {
                offlen = (*trie & OFFLEN) >> OFFLEN_SHIFT;