From 0425b0fcbee2ee3028ae40a10fa1471da52e2605 Mon Sep 17 00:00:00 2001 From: Joseph Sutton Date: Fri, 6 Oct 2023 12:36:13 +1300 Subject: [PATCH] libcli:auth: Remove unreachable code (CID 1272968) MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit For us to reach the statement ‘if (0 < len1)’, ‘len1’ must be equal to ‘len2’, and they must not both be equal to zero. That cannot be the case if ‘len1’ is equal to zero, and therefore the ‘else’ branch cannot be reached. Signed-off-by: Joseph Sutton Reviewed-by: Douglas Bagnall --- libcli/auth/msrpc_parse.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/libcli/auth/msrpc_parse.c b/libcli/auth/msrpc_parse.c index 8326261e838..d5661983a31 100644 --- a/libcli/auth/msrpc_parse.c +++ b/libcli/auth/msrpc_parse.c @@ -262,6 +262,8 @@ bool msrpc_parse(TALLOC_CTX *mem_ctx, goto cleanup; } } else { + size_t pull_len; + /* make sure its in the right format - be strict */ if ((len1 != len2) || (ptr + len1 < ptr) || (ptr + len1 < len1) || (ptr + len1 > blob->length)) { ret = false; @@ -278,20 +280,11 @@ bool msrpc_parse(TALLOC_CTX *mem_ctx, goto cleanup; } - if (0 < len1) { - size_t pull_len; - if (!convert_string_talloc(mem_ctx, CH_UTF16, CH_UNIX, - blob->data + ptr, len1, - ps, &pull_len)) { - ret = false; - goto cleanup; - } - } else { - *ps = talloc_strdup(mem_ctx, ""); - if (*ps == NULL) { - ret = false; - goto cleanup; - } + if (!convert_string_talloc(mem_ctx, CH_UTF16, CH_UNIX, + blob->data + ptr, len1, + ps, &pull_len)) { + ret = false; + goto cleanup; } } break; -- 2.47.3