From: Alan T. DeKok Date: Thu, 17 Oct 2019 21:51:48 +0000 (-0400) Subject: NUL terminate the result only if we should do it X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2df08ba37cddeb4c3feaf31ae3558df88e1e6aca;p=thirdparty%2Ffreeradius-server.git NUL terminate the result only if we should do it --- diff --git a/src/bin/unit_test_attribute.c b/src/bin/unit_test_attribute.c index 3a7f59733db..36cd61578b8 100644 --- a/src/bin/unit_test_attribute.c +++ b/src/bin/unit_test_attribute.c @@ -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, "")); @@ -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; /*