]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
don't convert octets from hex, and don't unescape strings
authorAlan T. DeKok <aland@freeradius.org>
Tue, 12 Oct 2021 14:26:36 +0000 (10:26 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 12 Oct 2021 14:26:36 +0000 (10:26 -0400)
src/protocols/tacacs/decode.c

index c067a8c0d58400da167b6d81e86cc18e07f30a8d..bc115dcbbf6ef6a85185a46e65c400610964c60b 100644 (file)
@@ -160,18 +160,43 @@ static int tacacs_decode_args(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr
                }
 
                /*
-                *      Parse the string, and try to convert it to the
-                *      underlying data type.  If it can't be
-                *      converted as a data type, just convert it as
-                *      Argument-List.
+                *      If it's OCTETS or STRING type, then just copy
+                *      the value verbatim.  But if it's zero length,
+                *      then don't do anything.
                 *
-                *      And if that fails, just ignore it completely.
+                *      Note that we copy things manually here because
+                *      we don't want the OCTETS type to be parsed as
+                *      hex.  And, we don't want the string type to be
+                *      unescaped.
                 */
-               if (fr_pair_value_from_str(vp, (char const *) value, arg_end - value, 0, true) < 0) {
-                       talloc_free(vp);
-                       if (da != parent) goto raw;
+               if (da->type == FR_TYPE_OCTETS) {
+                       if ((arg_end > value) &&
+                           (fr_pair_value_memdup(vp, value, arg_end - value, true) < 0)) {
+                               goto fail;
+                       }
+
+               } else if (da->type == FR_TYPE_STRING) {
+                       if ((arg_end > value) &&
+                           (fr_pair_value_bstrndup(vp, (char const *) value, arg_end - value, true) < 0)) {
+                               goto fail;
+                       }
 
-                       goto next;
+               } else {
+                       /*
+                        *      Parse the string, and try to convert it to the
+                        *      underlying data type.  If it can't be
+                        *      converted as a data type, just convert it as
+                        *      Argument-List.
+                        *
+                        *      And if that fails, just ignore it completely.
+                        */
+                       if (fr_pair_value_from_str(vp, (char const *) value, arg_end - value, 0, true) < 0) {
+                       fail:
+                               talloc_free(vp);
+                               if (da != parent) goto raw;
+
+                               goto next;
+                       }
                }
 
                fr_pair_append(out, vp);