diff options
-rw-r--r-- | libcli/util/ntstatus.h | 2 | ||||
-rw-r--r-- | source3/include/proto.h | 1 | ||||
-rw-r--r-- | source3/libsmb/nterr.c | 8 | ||||
-rw-r--r-- | source3/torture/torture.c | 6 | ||||
-rw-r--r-- | source4/libcli/util/nterr.c | 13 | ||||
-rw-r--r-- | source4/ntvfs/nbench/vfs_nbench.c | 39 |
6 files changed, 34 insertions, 35 deletions
diff --git a/libcli/util/ntstatus.h b/libcli/util/ntstatus.h index 3e7c6296954..d53f4bbc52f 100644 --- a/libcli/util/ntstatus.h +++ b/libcli/util/ntstatus.h @@ -641,7 +641,7 @@ const char *get_friendly_nt_error_msg(NTSTATUS nt_code); /***************************************************************************** returns an NT_STATUS constant as a string for inclusion in autogen C code *****************************************************************************/ -const char *get_nt_error_c_code(NTSTATUS nt_code); +const char *get_nt_error_c_code(void *mem_ctx, NTSTATUS nt_code); /***************************************************************************** returns the NT_STATUS constant matching the string supplied (as an NTSTATUS) diff --git a/source3/include/proto.h b/source3/include/proto.h index 2305a7ac687..a6e9cf9b5db 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -1976,7 +1976,6 @@ bool get_dc_name(const char *domain, const char *nt_errstr(NTSTATUS nt_code); const char *get_friendly_nt_error_msg(NTSTATUS nt_code); -const char *get_nt_error_c_code(NTSTATUS nt_code); NTSTATUS nt_status_string_to_code(const char *nt_status_str); NTSTATUS nt_status_squash(NTSTATUS nt_status); diff --git a/source3/libsmb/nterr.c b/source3/libsmb/nterr.c index e48f221be0d..0201aa2ddc8 100644 --- a/source3/libsmb/nterr.c +++ b/source3/libsmb/nterr.c @@ -740,7 +740,7 @@ const char *get_friendly_nt_error_msg(NTSTATUS nt_code) Returns an NT_STATUS constant as a string for inclusion in autogen C code. *****************************************************************************/ -const char *get_nt_error_c_code(NTSTATUS nt_code) +const char *get_nt_error_c_code(TALLOC_CTX *mem_ctx, NTSTATUS nt_code) { char *result; int idx = 0; @@ -748,14 +748,14 @@ const char *get_nt_error_c_code(NTSTATUS nt_code) while (nt_errs[idx].nt_errstr != NULL) { if (NT_STATUS_V(nt_errs[idx].nt_errcode) == NT_STATUS_V(nt_code)) { - return nt_errs[idx].nt_errstr; + result = talloc_strdup(mem_ctx, nt_errs[idx].nt_errstr); + return result; } idx++; } - result = talloc_asprintf(talloc_tos(), "NT_STATUS(0x%08x)", + result = talloc_asprintf(mem_ctx, "NT_STATUS(0x%08x)", NT_STATUS_V(nt_code)); - SMB_ASSERT(result); return result; } diff --git a/source3/torture/torture.c b/source3/torture/torture.c index b0e5cf8a027..fe9a5cb0937 100644 --- a/source3/torture/torture.c +++ b/source3/torture/torture.c @@ -5910,14 +5910,14 @@ static bool run_error_map_extract(int dummy) { if (NT_STATUS_V(nt_status) != error) { printf("/*\t{ This NT error code was 'sqashed'\n\t from %s to %s \n\t during the session setup }\n*/\n", - get_nt_error_c_code(NT_STATUS(error)), - get_nt_error_c_code(nt_status)); + get_nt_error_c_code(talloc_tos(), NT_STATUS(error)), + get_nt_error_c_code(talloc_tos(), nt_status)); } printf("\t{%s,\t%s,\t%s},\n", smb_dos_err_class(errclass), smb_dos_err_name(errclass, errnum), - get_nt_error_c_code(NT_STATUS(error))); + get_nt_error_c_code(talloc_tos(), NT_STATUS(error))); } return True; } diff --git a/source4/libcli/util/nterr.c b/source4/libcli/util/nterr.c index 99b5191273f..f2b15f03e82 100644 --- a/source4/libcli/util/nterr.c +++ b/source4/libcli/util/nterr.c @@ -897,22 +897,23 @@ const char *get_friendly_nt_error_msg(NTSTATUS nt_code) Returns an NT_STATUS constant as a string for inclusion in autogen C code. *****************************************************************************/ -const char *get_nt_error_c_code(NTSTATUS nt_code) +const char *get_nt_error_c_code(TALLOC_CTX *mem_ctx, NTSTATUS nt_code) { - static char out[40]; + char *result; int idx = 0; while (nt_errs[idx].nt_errstr != NULL) { if (NT_STATUS_V(nt_errs[idx].nt_errcode) == NT_STATUS_V(nt_code)) { - return nt_errs[idx].nt_errstr; + result = talloc_strdup(mem_ctx, nt_errs[idx].nt_errstr); + return result; } idx++; } - slprintf(out, sizeof(out), "NT_STATUS(0x%08x)", NT_STATUS_V(nt_code)); - - return out; + result = talloc_asprintf(mem_ctx, "NT_STATUS(0x%08x)", + NT_STATUS_V(nt_code)); + return result; } /***************************************************************************** diff --git a/source4/ntvfs/nbench/vfs_nbench.c b/source4/ntvfs/nbench/vfs_nbench.c index 35cd86f34db..565f2dafedc 100644 --- a/source4/ntvfs/nbench/vfs_nbench.c +++ b/source4/ntvfs/nbench/vfs_nbench.c @@ -165,10 +165,9 @@ static NTSTATUS nbench_disconnect(struct ntvfs_module_context *ntvfs) static void nbench_unlink_send(struct ntvfs_request *req) { union smb_unlink *unl = req->async_states->private_data; - nbench_log(req, "Unlink \"%s\" 0x%x %s\n", unl->unlink.in.pattern, unl->unlink.in.attrib, - get_nt_error_c_code(req->async_states->status)); + get_nt_error_c_code(req, req->async_states->status)); PASS_THRU_REP_POST(req); } @@ -213,7 +212,7 @@ static void nbench_chkpath_send(struct ntvfs_request *req) nbench_log(req, "Chkpath \"%s\" %s\n", cp->chkpath.in.path, - get_nt_error_c_code(req->async_states->status)); + get_nt_error_c_code(req, req->async_states->status)); PASS_THRU_REP_POST(req); } @@ -239,7 +238,7 @@ static void nbench_qpathinfo_send(struct ntvfs_request *req) nbench_log(req, "QUERY_PATH_INFORMATION \"%s\" %d %s\n", info->generic.in.file.path, info->generic.level, - get_nt_error_c_code(req->async_states->status)); + get_nt_error_c_code(req, req->async_states->status)); PASS_THRU_REP_POST(req); } @@ -264,7 +263,7 @@ static void nbench_qfileinfo_send(struct ntvfs_request *req) nbench_log(req, "QUERY_FILE_INFORMATION %s %d %s\n", nbench_ntvfs_handle_string(req, info->generic.in.file.ntvfs), info->generic.level, - get_nt_error_c_code(req->async_states->status)); + get_nt_error_c_code(req, req->async_states->status)); PASS_THRU_REP_POST(req); } @@ -289,7 +288,7 @@ static void nbench_setpathinfo_send(struct ntvfs_request *req) nbench_log(req, "SET_PATH_INFORMATION \"%s\" %d %s\n", st->generic.in.file.path, st->generic.level, - get_nt_error_c_code(req->async_states->status)); + get_nt_error_c_code(req, req->async_states->status)); PASS_THRU_REP_POST(req); } @@ -321,7 +320,7 @@ static void nbench_open_send(struct ntvfs_request *req) io->ntcreatex.in.create_options, io->ntcreatex.in.open_disposition, nbench_ntvfs_handle_string(req, io->ntcreatex.out.file.ntvfs), - get_nt_error_c_code(req->async_states->status)); + get_nt_error_c_code(req, req->async_states->status)); break; default: @@ -373,7 +372,7 @@ static void nbench_rmdir_send(struct ntvfs_request *req) nbench_log(req, "Rmdir \"%s\" %s\n", rd->in.path, - get_nt_error_c_code(req->async_states->status)); + get_nt_error_c_code(req, req->async_states->status)); PASS_THRU_REP_POST(req); } @@ -400,7 +399,7 @@ static void nbench_rename_send(struct ntvfs_request *req) nbench_log(req, "Rename \"%s\" \"%s\" %s\n", ren->rename.in.pattern1, ren->rename.in.pattern2, - get_nt_error_c_code(req->async_states->status)); + get_nt_error_c_code(req, req->async_states->status)); break; default: @@ -459,7 +458,7 @@ static void nbench_read_send(struct ntvfs_request *req) (int)rd->readx.in.offset, rd->readx.in.maxcnt, rd->readx.out.nread, - get_nt_error_c_code(req->async_states->status)); + get_nt_error_c_code(req, req->async_states->status)); break; default: nbench_log(req, "Read-%d - NOT HANDLED\n", @@ -497,7 +496,7 @@ static void nbench_write_send(struct ntvfs_request *req) (int)wr->writex.in.offset, wr->writex.in.count, wr->writex.out.nwritten, - get_nt_error_c_code(req->async_states->status)); + get_nt_error_c_code(req, req->async_states->status)); break; case RAW_WRITE_WRITE: @@ -509,7 +508,7 @@ static void nbench_write_send(struct ntvfs_request *req) wr->write.in.offset, wr->write.in.count, wr->write.out.nwritten, - get_nt_error_c_code(req->async_states->status)); + get_nt_error_c_code(req, req->async_states->status)); break; default: @@ -563,12 +562,12 @@ static void nbench_flush_send(struct ntvfs_request *req) case RAW_FLUSH_FLUSH: nbench_log(req, "Flush %s %s\n", nbench_ntvfs_handle_string(req, io->flush.in.file.ntvfs), - get_nt_error_c_code(req->async_states->status)); + get_nt_error_c_code(req, req->async_states->status)); break; case RAW_FLUSH_ALL: nbench_log(req, "Flush %d %s\n", 0xFFFF, - get_nt_error_c_code(req->async_states->status)); + get_nt_error_c_code(req, req->async_states->status)); break; default: nbench_log(req, "Flush-%d - NOT HANDLED\n", @@ -601,7 +600,7 @@ static void nbench_close_send(struct ntvfs_request *req) case RAW_CLOSE_CLOSE: nbench_log(req, "Close %s %s\n", nbench_ntvfs_handle_string(req, io->close.in.file.ntvfs), - get_nt_error_c_code(req->async_states->status)); + get_nt_error_c_code(req, req->async_states->status)); break; default: @@ -718,14 +717,14 @@ static void nbench_lock_send(struct ntvfs_request *req) nbench_ntvfs_handle_string(req, lck->lockx.in.file.ntvfs), (int)lck->lockx.in.locks[0].offset, (int)lck->lockx.in.locks[0].count, - get_nt_error_c_code(req->async_states->status)); + get_nt_error_c_code(req, req->async_states->status)); } else if (lck->generic.level == RAW_LOCK_LOCKX && lck->lockx.in.ulock_cnt == 1) { nbench_log(req, "UnlockX %s %d %d %s\n", nbench_ntvfs_handle_string(req, lck->lockx.in.file.ntvfs), (int)lck->lockx.in.locks[0].offset, (int)lck->lockx.in.locks[0].count, - get_nt_error_c_code(req->async_states->status)); + get_nt_error_c_code(req, req->async_states->status)); } else { nbench_log(req, "Lock-%d - NOT HANDLED\n", lck->generic.level); } @@ -753,7 +752,7 @@ static void nbench_setfileinfo_send(struct ntvfs_request *req) nbench_log(req, "SET_FILE_INFORMATION %s %d %s\n", nbench_ntvfs_handle_string(req, info->generic.in.file.ntvfs), info->generic.level, - get_nt_error_c_code(req->async_states->status)); + get_nt_error_c_code(req, req->async_states->status)); PASS_THRU_REP_POST(req); } @@ -778,7 +777,7 @@ static void nbench_fsinfo_send(struct ntvfs_request *req) nbench_log(req, "QUERY_FS_INFORMATION %d %s\n", fs->generic.level, - get_nt_error_c_code(req->async_states->status)); + get_nt_error_c_code(req, req->async_states->status)); PASS_THRU_REP_POST(req); } @@ -832,7 +831,7 @@ static void nbench_search_first_send(struct ntvfs_request *req) io->t2ffirst.data_level, io->t2ffirst.in.max_count, io->t2ffirst.out.count, - get_nt_error_c_code(req->async_states->status)); + get_nt_error_c_code(req, req->async_states->status)); break; default: |