From: Stefan Metzmacher Date: Fri, 18 Aug 2023 08:59:00 +0000 (+0200) Subject: libcli/util: let win_errstr() fallback to hresult_errstr() X-Git-Tag: talloc-2.4.2~1269 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=09daeba6962d9f2534762250eb3b172154aa4aaf;p=thirdparty%2Fsamba.git libcli/util: let win_errstr() fallback to hresult_errstr() Signed-off-by: Stefan Metzmacher Reviewed-by: Andrew Bartlett --- diff --git a/libcli/util/doserr.c b/libcli/util/doserr.c index b9553dfac5e..c30abc8df36 100644 --- a/libcli/util/doserr.c +++ b/libcli/util/doserr.c @@ -21,6 +21,7 @@ #include "replace.h" #include "libcli/util/werror.h" +#include "libcli/util/hresult.h" struct werror_code_struct { const char *dos_errstr; @@ -112,6 +113,19 @@ const char *win_errstr(WERROR werror) break; } + /* + * WERROR codes are 16-bit only, if the + * upper 16-bit are not 0, it's likely + * an HRESULT. + * + * E.g. we should display HRES_SEC_E_WRONG_PRINCIPAL instead of + * 'DOS code 0x80090322' + */ + if ((W_ERROR_V(werror) & 0xFFFF0000) != 0) { + HRESULT hres = HRES_ERROR(W_ERROR_V(werror)); + return hresult_errstr(hres); + } + slprintf(msg, sizeof(msg), "DOS code 0x%08x", W_ERROR_V(werror)); return msg; diff --git a/python/samba/tests/blackbox/ndrdump.py b/python/samba/tests/blackbox/ndrdump.py index c3b7ff70ac2..b7bdae68ee9 100644 --- a/python/samba/tests/blackbox/ndrdump.py +++ b/python/samba/tests/blackbox/ndrdump.py @@ -356,7 +356,7 @@ WARNING! 2 unread bytes info : union spoolss_FormInfo(case 0) needed : * needed : 0x00000000 (0) - result : DOS code 0xa9a9a900 + result : HRES code 0xa9a9a900 dump OK ''' try: