The branch, master has been updated
via 4fcdb01808f libcli/util: let nt_errstr() fallback to
hresult_errstr()
via 6e0e9c4efc8 s4:scripting: fix gen_hresult.py
from ff4c70e03ae lib: Fix error path memleaks in read_ea_list_entry()
https://git.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 4fcdb01808ff55935490e6bce452d1706680425d
Author: Stefan Metzmacher <[email protected]>
Date: Mon Dec 16 14:46:19 2024 +0100
libcli/util: let nt_errstr() fallback to hresult_errstr()
Sometimes NTSTATUS fields return things like
HRES_SEC_E_WRONG_PRINCIPAL.
Signed-off-by: Stefan Metzmacher <[email protected]>
Reviewed-by: Guenther Deschner <[email protected]>
Autobuild-User(master): Günther Deschner <[email protected]>
Autobuild-Date(master): Wed Dec 18 18:30:08 UTC 2024 on atb-devel-224
commit 6e0e9c4efc86f5ec4566aa0220ed4a74ad5436c1
Author: Stefan Metzmacher <[email protected]>
Date: Mon Dec 16 14:43:41 2024 +0100
s4:scripting: fix gen_hresult.py
Commit 6877e4849e81ed8f7f355fa4069f13a134e999ce reversed the
return values of hresult_errstr() and hresult_errstr_const().
hresult_errstr() should return "HRES_SEC_E_WRONG_PRINCIPAL",
while hresult_errstr_const() should return
"The target principal name is incorrect.".
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15769
Signed-off-by: Stefan Metzmacher <[email protected]>
Reviewed-by: Guenther Deschner <[email protected]>
-----------------------------------------------------------------------
Summary of changes:
libcli/util/nterr.c | 15 +++++++++++++++
source4/scripting/bin/gen_hresult.py | 4 ++--
2 files changed, 17 insertions(+), 2 deletions(-)
Changeset truncated at 500 lines:
diff --git a/libcli/util/nterr.c b/libcli/util/nterr.c
index cfe89f2d7ea..91042024c9d 100644
--- a/libcli/util/nterr.c
+++ b/libcli/util/nterr.c
@@ -346,6 +346,21 @@ const char *nt_errstr(NTSTATUS nt_code)
idx++;
}
+ /*
+ * NTSTATUS codes have 0xC000 in the upper 16-bit, if the
+ * upper 16-bit are not 0 and not 0xC000, it's likely
+ * an HRESULT.
+ *
+ * E.g. we should display HRES_SEC_E_WRONG_PRINCIPAL instead of
+ * 'NT code 0x80090322'
+ */
+ if ((NT_STATUS_V(nt_code) & 0xFFFF0000) != 0 &&
+ (NT_STATUS_V(nt_code) & 0xFFFF0000) != 0xC0000000)
+ {
+ HRESULT hres = HRES_ERROR(NT_STATUS_V(nt_code));
+ return hresult_errstr(hres);
+ }
+
/*
* This should not really happen, we should have all error codes
* available. We have a problem that this might get wrongly
diff --git a/source4/scripting/bin/gen_hresult.py
b/source4/scripting/bin/gen_hresult.py
index 3caca259436..dec0adf11be 100755
--- a/source4/scripting/bin/gen_hresult.py
+++ b/source4/scripting/bin/gen_hresult.py
@@ -101,7 +101,7 @@ def generateSourceFile(out_file, errors):
out_file.write(" switch (HRES_ERROR_V(err_code)) {\n")
for err in errors:
out_file.write(f' case 0x{err.err_code:X}:\n')
- out_file.write(f' result = \"{err.err_define}\";\n')
+ out_file.write(f' result = \"{err.err_string}\";\n')
out_file.write(f' break;\n')
out_file.write(" }\n")
out_file.write("\n")
@@ -120,7 +120,7 @@ def generateSourceFile(out_file, errors):
out_file.write(" switch (HRES_ERROR_V(err_code)) {\n")
for err in errors:
out_file.write(f' case 0x{err.err_code:X}:\n')
- out_file.write(f' return \"{err.err_string}\";\n')
+ out_file.write(f' return \"{err.err_define}\";\n')
out_file.write(f' break;\n')
out_file.write(" }\n")
out_file.write(" snprintf(msg, sizeof(msg), \"HRES code 0x%08x\",
HRES_ERROR_V(err_code));\n")
--
Samba Shared Repository