]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
NUL terminate the result only if we should do it
authorAlan T. DeKok <aland@freeradius.org>
Thu, 17 Oct 2019 21:51:48 +0000 (17:51 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Thu, 17 Oct 2019 21:51:48 +0000 (17:51 -0400)
src/bin/unit_test_attribute.c

index 3a7f59733dbea51cc681ca7be52d2875f76cb8b2..36cd61578b8a371ab8dc27fb7f663de62a67ae7c 100644 (file)
@@ -1696,9 +1696,6 @@ static int process_file(bool *exit_now, TALLOC_CTX *ctx, CONF_SECTION *features,
                        data_len = command->func(&result, &cc, data, data_len, p, strlen(p));
                }
 
-               rad_assert((size_t)data_len < sizeof(data));
-               data[data_len] = '\0';                  /* Ensure the data buffer is \0 terminated */
-
                DEBUG2("%s[%d]: --> %s", filename, cc.lineno,
                       fr_table_str_by_value(command_rcode_table, result.rcode, "<INVALID>"));
 
@@ -1707,6 +1704,8 @@ static int process_file(bool *exit_now, TALLOC_CTX *ctx, CONF_SECTION *features,
                 *      Command completed successfully
                 */
                case RESULT_OK:
+                       rad_assert((size_t)data_len < sizeof(data));
+                       data[data_len] = '\0';                  /* Ensure the data buffer is \0 terminated */
                        continue;
 
                /*