]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
util:charset: Remove unreachable code (CID 1272948)
authorJoseph Sutton <josephsutton@catalyst.net.nz>
Thu, 5 Oct 2023 21:54:57 +0000 (10:54 +1300)
committerDouglas Bagnall <dbagnall@samba.org>
Wed, 28 Aug 2024 04:24:39 +0000 (04:24 +0000)
Suppose that ‘slen’ is equal to (size_t)-1. A few lines up, we had:

    if (lastp != 0) goto slow_path;

Therefore, ‘lastp’ must evaluate to false.

Now suppose that ‘slen’ is not equal to (size_t)-1. In that case, we
would have executed:

    if (slen != 0) goto slow_path;

Therefore, ‘slen’ must evaluate to false.

Consequently, this code can be seen to be unreachable.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
lib/util/charset/convert_string.c

index 859b002ecbcf97ca4021331c3fbc24e88c504fd7..b15273ce2bb56e4b936d4d1c71f720622f67eddb 100644 (file)
@@ -210,15 +210,6 @@ bool convert_string_error_handle(struct smb_iconv_handle *ic,
                }
 
                *converted_size = retval;
-
-               if (!dlen) {
-                       /* Even if we fast path we should note if we ran out of room. */
-                       if (((slen != (size_t)-1) && slen) ||
-                                       ((slen == (size_t)-1) && lastp)) {
-                               errno = E2BIG;
-                               return false;
-                       }
-               }
                return true;
 
        slow_path: