diff options
author | Volker Lendecke <vl@samba.org> | 2014-09-17 15:09:52 +0200 |
---|---|---|
committer | Volker Lendecke <vl@samba.org> | 2014-09-18 20:36:11 +0200 |
commit | 3ffff13e0d66ac6f871c3d87d15c5c3c8095ed33 (patch) | |
tree | 8403fcb200bb5b8c04c4775c1ec9f4985e2f5edb /libcli/util | |
parent | fb9067c789263d5e2fcc26adb46463b974ccdaae (diff) | |
download | samba-3ffff13e0d66ac6f871c3d87d15c5c3c8095ed33.tar.gz |
lib: Fix samba-util dep in "errors" module
This piece of code pulls in talloc_stackframe and smb_panic into what
should be a very simple mapping library. I'm trying to reduce our
dependencies right now a bit, and I think the use cases that this fixes
(unknown NTSTATUS together with double nt_errstr() calls in the same
DEBUG) are rare enough that this is not justified.
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
Diffstat (limited to 'libcli/util')
-rw-r--r-- | libcli/util/nterr.c | 24 | ||||
-rw-r--r-- | libcli/util/wscript_build | 2 |
2 files changed, 9 insertions, 17 deletions
diff --git a/libcli/util/nterr.c b/libcli/util/nterr.c index 9f90f7a95fa..dbf399b82af 100644 --- a/libcli/util/nterr.c +++ b/libcli/util/nterr.c @@ -3905,8 +3905,8 @@ NTSTATUS nt_status_squash(NTSTATUS nt_status) const char *nt_errstr(NTSTATUS nt_code) { + static char msg[20]; int idx = 0; - char *result; while (nt_errs[idx].nt_errstr != NULL) { if (NT_STATUS_V(nt_errs[idx].nt_errcode) == @@ -3916,22 +3916,14 @@ const char *nt_errstr(NTSTATUS nt_code) idx++; } - if (!talloc_stackframe_exists()) { - /* prevent memory leaks from talloc_tos() by using a - * static area. This means the caller will overwrite - * the string with subsequent calls, which can cause - * display of the wrong error. If that happens the - * caller should have a talloc stackframe - */ - static char msg[20]; - snprintf(msg, sizeof(msg), "NT code 0x%08x", NT_STATUS_V(nt_code)); - return msg; - } + /* + * This should not really happen, we should have all error codes + * available. We have a problem that this might get wrongly + * overwritten by later calls in the same DEBUG statement. + */ - result = talloc_asprintf(talloc_tos(), "NT code 0x%08x", - NT_STATUS_V(nt_code)); - SMB_ASSERT(result != NULL); - return result; + snprintf(msg, sizeof(msg), "NT code 0x%08x", NT_STATUS_V(nt_code)); + return msg; } /************************************************************************ diff --git a/libcli/util/wscript_build b/libcli/util/wscript_build index 3bfa4b1cdc6..ccb882d7618 100644 --- a/libcli/util/wscript_build +++ b/libcli/util/wscript_build @@ -5,7 +5,7 @@ bld.SAMBA_LIBRARY('errors', public_headers='error.h ntstatus.h doserr.h werror.h hresult.h', header_path='core', source='doserr.c errormap.c nterr.c errmap_unix.c hresult.c', - public_deps='talloc samba-util', + public_deps='talloc samba-debug', private_library=True ) |