]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Shorten passwords from the end. Fixes #1013
authorAlan T. DeKok <aland@freeradius.org>
Fri, 15 May 2015 14:02:54 +0000 (10:02 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Fri, 15 May 2015 14:02:54 +0000 (10:02 -0400)
src/lib/radius.c

index 4092019ebbdd0a646d48b39640629a4d3cd78ad5..045143da5204450e091f84144781d5cbc388a84b 100644 (file)
@@ -3450,7 +3450,18 @@ ssize_t data2vp(TALLOC_CTX *ctx,
                                             packet->vector);
                        }
                        buffer[253] = '\0';
-                       datalen = strlen((char *) buffer);
+
+                       /*
+                        *      Take off trailing zeros from the END.
+                        *      This allows passwords to have zeros in
+                        *      the middle of a field.
+                        *
+                        *      However, if the password has a zero at
+                        *      the end, it will get mashed by this
+                        *      code.  There's really no way around
+                        *      that.
+                        */
+                       while ((datalen > 0) && (buffer[datalen - 1] == '\0')) datalen--;
                        break;
 
                /*