]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
libcli:auth: Remove unreachable code (CID 1272968)
authorJoseph Sutton <josephsutton@catalyst.net.nz>
Thu, 5 Oct 2023 23:36:13 +0000 (12:36 +1300)
committerDouglas Bagnall <dbagnall@samba.org>
Wed, 28 Aug 2024 04:24:39 +0000 (04:24 +0000)
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 <josephsutton@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
libcli/auth/msrpc_parse.c

index 8326261e8387de2a6e79c75b2f238c75ec226f2c..d5661983a314cf14f2de4a8aaa7c6463d89129c2 100644 (file)
@@ -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;