]> git.decadent.org.uk Git - nfs-utils.git/commitdiff
idmapd: Fix decoding of octal encoded fields
authorJan-Marek Glogowski <glogow@fbihome.de>
Tue, 20 Sep 2011 18:33:22 +0000 (14:33 -0400)
committerLuk Claes <luk@debian.org>
Sun, 2 Oct 2011 14:16:48 +0000 (16:16 +0200)
The decoded octal will always be positive and (char) -1 is negative. Any
field containing an encoded octal will be rejected.

As the encoded value should be an unsigned char, fix the check to reject
all values > (unsigned char) -1 = UCHAR_MAX, as this indicate an error
in the encoding.

Signed-off-by: Jan-Marek Glogowski <glogow@fbihome.de>
Signed-off-by: Steve Dickson <steved@redhat.com>
utils/idmapd/idmapd.c

index 76a56ef6b58f7a8f0d5efa8c7f2f6350f81e3a14..19d91147eaed2a990694a33e683e99e1fcef892c 100644 (file)
@@ -925,9 +925,9 @@ getfield(char **bpp, char *fld, size_t fldsz)
                if (*bp == '\\') {
                        if ((n = sscanf(bp, "\\%03o", &val)) != 1)
                                return (-1);
-                       if (val > (char)-1)
+                       if (val > UCHAR_MAX)
                                return (-1);
-                       *fld++ = (char)val;
+                       *fld++ = val;
                        bp += 4;
                } else {
                        *fld++ = *bp;