]> git.ipfire.org Git - thirdparty/xtables-addons.git/commitdiff
xt_SYSRQ: fix a couple of problems
authorJohn Haxby <jengelh@medozas.de>
Wed, 9 Jun 2010 15:36:28 +0000 (16:36 +0100)
committerJan Engelhardt <jengelh@medozas.de>
Fri, 25 Jun 2010 10:20:26 +0000 (12:20 +0200)
The first problem is that the error response from crypto_alloc_hash()
should be extracted from the pointer before setting the pointer to NULL.

The second error is that only the first half of the password hash is
checked which slightly weakens the password checking.

Signed-off-by: John Haxby <john.haxby@oracle.com>
extensions/xt_SYSRQ.c

index e0b6aa03b885b103357cd4ab9f6bc9ba10c6d63f..a01305143878c003ac12b8b6db7f3871cf54b351 100644 (file)
@@ -135,13 +135,13 @@ static unsigned int sysrq_tg(const void *pdata, uint16_t len)
                        "0123456789abcdef"[sysrq_digest[i] & 0xf];
        }
        sysrq_hexdigest[2*sysrq_digest_size] = '\0';
-       if (len - n < sysrq_digest_size) {
+       if (len - n < sysrq_digest_size * 2) {
                if (sysrq_debug)
                        printk(KERN_INFO KBUILD_MODNAME ": Short digest,"
                               " expected %s\n", sysrq_hexdigest);
                return NF_DROP;
        }
-       if (strncmp(data + n, sysrq_hexdigest, sysrq_digest_size) != 0) {
+       if (strncmp(data + n, sysrq_hexdigest, sysrq_digest_size * 2) != 0) {
                if (sysrq_debug)
                        printk(KERN_INFO KBUILD_MODNAME ": Bad digest,"
                               " expected %s\n", sysrq_hexdigest);
@@ -324,8 +324,8 @@ static int __init sysrq_crypto_init(void)
                printk(KERN_WARNING KBUILD_MODNAME
                        ": Error: Could not find or load %s hash\n",
                        sysrq_hash);
-               sysrq_tfm = NULL;
                ret = PTR_ERR(sysrq_tfm);
+               sysrq_tfm = NULL;
                goto fail;
        }
        sysrq_digest_size = crypto_hash_digestsize(sysrq_tfm);