]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
nsswitch:krb5_plugin: Avoid a possible double free
authorAndreas Schneider <asn@samba.org>
Tue, 18 Jun 2024 13:45:53 +0000 (15:45 +0200)
committerAndreas Schneider <asn@cryptomilk.org>
Mon, 24 Jun 2024 06:14:35 +0000 (06:14 +0000)
Found by Covscan.

"Error: USE_AFTER_FREE (CWE-416):
samba-4.20.0rc2/nsswitch/krb5_plugin/winbind_krb5_localauth.c:122: freed_arg: ""wbcFreeMemory"" frees ""pwd"".
samba-4.20.0rc2/nsswitch/krb5_plugin/winbind_krb5_localauth.c:144: pass_freed_arg: Passing freed pointer ""pwd"" as an argument to ""wbcFreeMemory"".
  142|    break;
  143|    }
  144|->  wbcFreeMemory(pwd);
  145|    if (code != 0) {
  146|    goto out;"

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
nsswitch/krb5_plugin/winbind_krb5_localauth.c

index 751dfd1674b4f11a0ef845b1038d3a4d8b6e365a..f610b0cdf8cbce1e79351d46cdf350b4a8aa3316 100644 (file)
@@ -120,6 +120,7 @@ static krb5_error_code winbind_userok(krb5_context context,
                break;
        }
        wbcFreeMemory(pwd);
+       pwd = NULL;
        if (code != 0) {
                goto out;
        }