summaryrefslogtreecommitdiff
path: root/source3/libsmb
diff options
context:
space:
mode:
authorVolker Lendecke <Volker.Lendecke@SerNet.DE>2007-11-11 15:30:01 +0100
committerJeremy Allison <jra@samba.org>2007-11-11 21:34:40 -0800
commit6069670f1bebc37527c8363a72a653e43fff7c0b (patch)
tree65e70d7b07a35fc977c35c2aaef49492cead627a /source3/libsmb
parent7e9d639ed1584c2f7cd3556ce3e93974851f74c6 (diff)
downloadsamba-6069670f1bebc37527c8363a72a653e43fff7c0b.tar.gz
samba-6069670f1bebc37527c8363a72a653e43fff7c0b.tar.bz2
samba-6069670f1bebc37527c8363a72a653e43fff7c0b.zip
Some pstring removal
Hi! Feel free to push :-) Volker From 7fae6b3709a973bd0a5a13d3f5c880c61d5e35de Mon Sep 17 00:00:00 2001 From: Volker Lendecke <vl@sernet.de> Date: Sun, 11 Nov 2007 15:28:59 +0100 Subject: [PATCH] Remove some static pstrings (This used to be commit c3a66b4ee97a902c5cf43c3bb145541849a029ed)
Diffstat (limited to 'source3/libsmb')
-rw-r--r--source3/libsmb/clierror.c14
-rw-r--r--source3/libsmb/dcerpc_err.c9
-rw-r--r--source3/libsmb/nterr.c18
-rw-r--r--source3/libsmb/smberr.c60
4 files changed, 61 insertions, 40 deletions
diff --git a/source3/libsmb/clierror.c b/source3/libsmb/clierror.c
index 1c35bcf146..2232ee27a7 100644
--- a/source3/libsmb/clierror.c
+++ b/source3/libsmb/clierror.c
@@ -98,14 +98,15 @@ static NTSTATUS cli_smb_rw_error_to_ntstatus(struct cli_state *cli)
const char *cli_errstr(struct cli_state *cli)
{
- static fstring cli_error_message;
+ fstring cli_error_message;
uint32 flgs2 = SVAL(cli->inbuf,smb_flg2), errnum;
uint8 errclass;
int i;
+ char *result;
if (!cli->initialised) {
fstrcpy(cli_error_message, "[Programmer's error] cli_errstr called on unitialized cli_stat struct!\n");
- return cli_error_message;
+ goto done;
}
/* Was it server socket error ? */
@@ -137,7 +138,7 @@ const char *cli_errstr(struct cli_state *cli)
"Unknown error code %d\n", cli->smb_rw_error );
break;
}
- return cli_error_message;
+ goto done;
}
/* Case #1: RAP error */
@@ -151,7 +152,7 @@ const char *cli_errstr(struct cli_state *cli)
slprintf(cli_error_message, sizeof(cli_error_message) - 1, "RAP code %d",
cli->rap_error);
- return cli_error_message;
+ goto done;
}
/* Case #2: 32-bit NT errors */
@@ -166,6 +167,11 @@ const char *cli_errstr(struct cli_state *cli)
/* Case #3: SMB error */
return cli_smb_errstr(cli);
+
+ done:
+ result = talloc_strdup(talloc_tos(), cli_error_message);
+ SMB_ASSERT(result);
+ return result;
}
diff --git a/source3/libsmb/dcerpc_err.c b/source3/libsmb/dcerpc_err.c
index b1874b943f..900b8d769f 100644
--- a/source3/libsmb/dcerpc_err.c
+++ b/source3/libsmb/dcerpc_err.c
@@ -38,11 +38,9 @@ static const struct dcerpc_fault_table dcerpc_faults[] =
const char *dcerpc_errstr(uint32 fault_code)
{
- static pstring msg;
+ char *result;
int idx = 0;
- slprintf(msg, sizeof(msg), "DCERPC fault 0x%08x", fault_code);
-
while (dcerpc_faults[idx].errstr != NULL) {
if (dcerpc_faults[idx].faultcode == fault_code) {
return dcerpc_faults[idx].errstr;
@@ -50,5 +48,8 @@ const char *dcerpc_errstr(uint32 fault_code)
idx++;
}
- return msg;
+ result = talloc_asprintf(talloc_tos(), "DCERPC fault 0x%08x",
+ fault_code);
+ SMB_ASSERT(result != NULL);
+ return result;
}
diff --git a/source3/libsmb/nterr.c b/source3/libsmb/nterr.c
index d88e650c9c..cf443f2339 100644
--- a/source3/libsmb/nterr.c
+++ b/source3/libsmb/nterr.c
@@ -647,8 +647,8 @@ nt_err_code_struct nt_err_desc[] =
const char *nt_errstr(NTSTATUS nt_code)
{
- static pstring msg;
int idx = 0;
+ char *result;
#ifdef HAVE_LDAP
if (NT_STATUS_TYPE(nt_code) == NT_STATUS_TYPE_LDAP) {
@@ -656,8 +656,6 @@ const char *nt_errstr(NTSTATUS nt_code)
}
#endif
- slprintf(msg, sizeof(msg), "NT code 0x%08x", NT_STATUS_V(nt_code));
-
while (nt_errs[idx].nt_errstr != NULL) {
if (NT_STATUS_EQUAL(nt_errs[idx].nt_errcode, nt_code)) {
return nt_errs[idx].nt_errstr;
@@ -665,7 +663,10 @@ const char *nt_errstr(NTSTATUS nt_code)
idx++;
}
- return msg;
+ result = talloc_asprintf(talloc_tos(), "NT code 0x%08x",
+ NT_STATUS_V(nt_code));
+ SMB_ASSERT(result != NULL);
+ return result;
}
/************************************************************************
@@ -694,7 +695,7 @@ const char *get_friendly_nt_error_msg(NTSTATUS nt_code)
const char *get_nt_error_c_code(NTSTATUS nt_code)
{
- static pstring out;
+ char *result;
int idx = 0;
while (nt_errs[idx].nt_errstr != NULL) {
@@ -705,9 +706,10 @@ const char *get_nt_error_c_code(NTSTATUS nt_code)
idx++;
}
- slprintf(out, sizeof(out), "NT_STATUS(0x%08x)", NT_STATUS_V(nt_code));
-
- return out;
+ result = talloc_asprintf(talloc_tos(), "NT_STATUS(0x%08x)",
+ NT_STATUS_V(nt_code));
+ SMB_ASSERT(result);
+ return result;
}
/*****************************************************************************
diff --git a/source3/libsmb/smberr.c b/source3/libsmb/smberr.c
index 1d81011d92..f4a13983f0 100644
--- a/source3/libsmb/smberr.c
+++ b/source3/libsmb/smberr.c
@@ -160,7 +160,7 @@ return a SMB error name from a class and code
****************************************************************************/
const char *smb_dos_err_name(uint8 e_class, uint16 num)
{
- static pstring ret;
+ char *result;
int i,j;
for (i=0;err_classes[i].e_class;i++)
@@ -172,12 +172,15 @@ const char *smb_dos_err_name(uint8 e_class, uint16 num)
return err[j].name;
}
}
- slprintf(ret, sizeof(ret) - 1, "%d",num);
- return ret;
+ result = talloc_asprintf(talloc_tos(), "%d", num);
+ SMB_ASSERT(result != NULL);
+ return result;
}
- slprintf(ret, sizeof(ret) - 1, "Error: Unknown error class (%d,%d)",e_class,num);
- return(ret);
+ result = talloc_asprintf(talloc_tos(), "Error: Unknown error class "
+ "(%d,%d)", e_class,num);
+ SMB_ASSERT(result != NULL);
+ return result;
}
/* Return a string for a DOS error */
@@ -196,17 +199,19 @@ return a SMB error class name as a string.
****************************************************************************/
const char *smb_dos_err_class(uint8 e_class)
{
- static pstring ret;
+ char *result;
int i;
-
+
for (i=0;err_classes[i].e_class;i++) {
if (err_classes[i].code == e_class) {
return err_classes[i].e_class;
}
}
-
- slprintf(ret, sizeof(ret) - 1, "Error: Unknown class (%d)",e_class);
- return(ret);
+
+ result = talloc_asprintf(talloc_tos(), "Error: Unknown class (%d)",
+ e_class);
+ SMB_ASSERT(result != NULL);
+ return result;
}
/****************************************************************************
@@ -214,11 +219,11 @@ return a SMB string from an SMB buffer
****************************************************************************/
char *smb_dos_errstr(char *inbuf)
{
- static pstring ret;
+ char *result;
int e_class = CVAL(inbuf,smb_rcls);
int num = SVAL(inbuf,smb_err);
int i,j;
-
+
for (i=0;err_classes[i].e_class;i++)
if (err_classes[i].code == e_class) {
if (err_classes[i].err_msgs) {
@@ -226,22 +231,29 @@ char *smb_dos_errstr(char *inbuf)
for (j=0;err[j].name;j++)
if (num == err[j].code) {
if (DEBUGLEVEL > 0)
- slprintf(ret, sizeof(ret) - 1, "%s - %s (%s)",
- err_classes[i].e_class,
- err[j].name,err[j].message);
+ result = talloc_asprintf(
+ talloc_tos(), "%s - %s (%s)",
+ err_classes[i].e_class,
+ err[j].name,err[j].message);
else
- slprintf(ret, sizeof(ret) - 1, "%s - %s",
- err_classes[i].e_class,err[j].name);
- return ret;
+ result = talloc_asprintf(
+ talloc_tos(), "%s - %s",
+ err_classes[i].e_class,
+ err[j].name);
+ goto done;
}
}
-
- slprintf(ret, sizeof(ret) - 1, "%s - %d",err_classes[i].e_class,num);
- return ret;
+
+ result = talloc_asprintf(talloc_tos(), "%s - %d",
+ err_classes[i].e_class, num);
+ goto done;
}
-
- slprintf(ret, sizeof(ret) - 1, "Error: Unknown error (%d,%d)",e_class,num);
- return(ret);
+
+ result = talloc_asprintf(talloc_tos(), "Error: Unknown error (%d,%d)",
+ e_class, num);
+ done:
+ SMB_ASSERT(result != NULL);
+ return result;
}
/*****************************************************************************