From: Jan-Marek Glogowski Date: Tue, 20 Sep 2011 18:33:22 +0000 (-0400) Subject: idmapd: Fix decoding of octal encoded fields X-Git-Tag: debian/1%1.2.5-1~11^2~7 X-Git-Url: https://git.decadent.org.uk/gitweb/?a=commitdiff_plain;h=eabbf0963d28735657f93da60fc098ee99b69858;p=nfs-utils.git idmapd: Fix decoding of octal encoded fields 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 Signed-off-by: Steve Dickson --- diff --git a/utils/idmapd/idmapd.c b/utils/idmapd/idmapd.c index 76a56ef..19d9114 100644 --- a/utils/idmapd/idmapd.c +++ b/utils/idmapd/idmapd.c @@ -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;