From: Colin King <colin.king@canonical.com>
To: Masahiro Yamada <yamada.masahiro@socionext.com>,
Michal Marek <michal.lkml@markovi.net>,
linux-kbuild@vger.kernel.org
Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH][next] unicode: fix dereference of a potentially null pointer
Date: Fri, 26 Apr 2019 23:22:37 +0100 [thread overview]
Message-ID: <20190426222237.13209-1-colin.king@canonical.com> (raw)
From: Colin Ian King <colin.king@canonical.com>
The pointer 'tree' is deferenced when assigning pointer 'trie', however
trie is being null checked a few lines later, so it could potentially
be null. Fix the potential null pointer dereference by only dereferencing
it after it has been null checked.
Addresses-Coverity: ("Dereference before null check")
Fixes: b08fcacaaaf4 ("unicode: introduce UTF-8 character database")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
scripts/mkutf8data.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/scripts/mkutf8data.c b/scripts/mkutf8data.c
index 12ce94b43be6..0563ba679bbb 100644
--- a/scripts/mkutf8data.c
+++ b/scripts/mkutf8data.c
@@ -2706,7 +2706,7 @@ static utf8leaf_t *utf8hangul(const char *str, unsigned char *hangul)
static utf8leaf_t *utf8nlookup(struct tree *tree, unsigned char *hangul,
const char *s, size_t len)
{
- utf8trie_t *trie = utf8data + tree->index;
+ utf8trie_t *trie;
int offlen;
int offset;
int mask;
@@ -2716,6 +2716,7 @@ static utf8leaf_t *utf8nlookup(struct tree *tree, unsigned char *hangul,
return NULL;
if (len == 0)
return NULL;
+ trie = utf8data + tree->index;
node = 1;
while (node) {
offlen = (*trie & OFFLEN) >> OFFLEN_SHIFT;
--
2.20.1
next reply other threads:[~2019-04-26 22:22 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-26 22:22 Colin King [this message]
2019-04-27 6:29 ` [PATCH][next] unicode: fix dereference of a potentially null pointer Masahiro Yamada
2019-04-28 11:02 ` Gabriel Krisman Bertazi
2019-04-28 13:21 ` Theodore Ts'o
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190426222237.13209-1-colin.king@canonical.com \
--to=colin.king@canonical.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michal.lkml@markovi.net \
--cc=yamada.masahiro@socionext.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).