Skip to contentSkip to conversation

idmapd: Fix decoding of octal encoded fields.

PATCH In review Jan-Marek Glogowski 2 participants 2 messages Sep 20, 2011 – Sep 21, 2011 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

utils/idmapd/idmapd.c +2 -2
@@ -925,9 +925,9 @@ getfield(char **bpp, char *fld, size_t f
 		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;

A message that is not in the archive (sent off-list or not yet received): alpine.DEB.2.02.1109201952540.26882-icXI/[email protected]

#2 lore raw
Quoted 5 lines · Jan-Marek Glogowski

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.

Committed..

steved.

Quoted 19 lines
utils/idmapd/idmapd.c +2 -2
@@ -925,9 +925,9 @@ getfield(char **bpp, char *fld, size_t f
         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;
Signature · 3 lines
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html