]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
systemd-hwdb: fix unsigned and signed comparison problem
authorhuyubiao <huyubiao@huawei.com>
Tue, 26 Sep 2023 06:46:55 +0000 (14:46 +0800)
committerLuca Boccassi <luca.boccassi@gmail.com>
Tue, 26 Sep 2023 16:38:16 +0000 (17:38 +0100)
...
uint8_t c;
struct trie_node *child;

for (p = 0; (c = trie->strings->buf[node->prefix_off + p]); p++) {
        _cleanup_free_ struct trie_node *new_child = NULL;
        _cleanup_free_ char *s = NULL;
        ssize_t off;
if (c == search[i + p])
        continue;
...
When '®' is present in search, c is 194, search[i + p] is -62, c is not equal to search[i + p], but c should be equal to search[i + p].

src/shared/hwdb-util.c

index 12621b7f89d19fb40e7d579a30aa23add9b4d651..f67e917b533c36316a4bb8b7aea6ca7a3774e053 100644 (file)
@@ -193,7 +193,7 @@ static int trie_insert(struct trie *trie, struct trie_node *node, const char *se
 
         for (size_t i = 0;; i++) {
                 size_t p;
-                uint8_t c;
+                char c;
                 struct trie_node *child;
 
                 for (p = 0; (c = trie->strings->buf[node->prefix_off + p]); p++) {