svn commit: samba r23661 - in branches: SAMBA_3_0/source/rpc_server SAMBA_3_0_26/source/rpc_server

vlendec at samba.org vlendec at samba.org
Fri Jun 29 17:40:41 GMT 2007


Author: vlendec
Date: 2007-06-29 17:40:37 +0000 (Fri, 29 Jun 2007)
New Revision: 23661

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=23661

Log:
Another static pstring
Modified:
   branches/SAMBA_3_0/source/rpc_server/srv_ntsvcs_nt.c
   branches/SAMBA_3_0_26/source/rpc_server/srv_ntsvcs_nt.c


Changeset:
Modified: branches/SAMBA_3_0/source/rpc_server/srv_ntsvcs_nt.c
===================================================================
--- branches/SAMBA_3_0/source/rpc_server/srv_ntsvcs_nt.c	2007-06-29 17:27:59 UTC (rev 23660)
+++ branches/SAMBA_3_0/source/rpc_server/srv_ntsvcs_nt.c	2007-06-29 17:40:37 UTC (rev 23661)
@@ -27,13 +27,9 @@
 /********************************************************************
 ********************************************************************/
 
-static char* get_device_path( const char *device )
+static char* get_device_path(TALLOC_CTX *mem_ctx, const char *device )
 {
-	static pstring path;
-
-	pstr_sprintf( path, "ROOT\\Legacy_%s\\0000", device );
-
-	return path;
+	return talloc_asprintf(mem_ctx, "ROOT\\Legacy_%s\\0000", device);
 }
 
 /********************************************************************
@@ -52,16 +48,21 @@
 WERROR _ntsvcs_get_device_list_size( pipes_struct *p, NTSVCS_Q_GET_DEVICE_LIST_SIZE *q_u, NTSVCS_R_GET_DEVICE_LIST_SIZE *r_u )
 {
 	fstring device;
-	const char *devicepath;
+	char *devicepath;
 
 	if ( !q_u->devicename )
 		return WERR_ACCESS_DENIED;
 
 	rpcstr_pull(device, q_u->devicename->buffer, sizeof(device), q_u->devicename->uni_str_len*2, 0);
-	devicepath = get_device_path( device );
 
+	if (!(devicepath = get_device_path(p->mem_ctx, device))) {
+		return WERR_NOMEM;
+	}
+
 	r_u->size = strlen(devicepath) + 2;
 
+	TALLOC_FREE(devicepath);
+
 	return WERR_OK;
 }
 
@@ -72,17 +73,21 @@
 WERROR _ntsvcs_get_device_list( pipes_struct *p, NTSVCS_Q_GET_DEVICE_LIST *q_u, NTSVCS_R_GET_DEVICE_LIST *r_u )
 {
 	fstring device;
-	const char *devicepath;
+	char *devicepath;
 
 	if ( !q_u->devicename )
 		return WERR_ACCESS_DENIED;
 
 	rpcstr_pull(device, q_u->devicename->buffer, sizeof(device), q_u->devicename->uni_str_len*2, 0);
-	devicepath = get_device_path( device );
 
+	if (!(devicepath = get_device_path(p->mem_ctx, device))) {
+		return WERR_NOMEM;
+	}
+
 	/* This has to be DOUBLE NULL terminated */
 
 	init_unistr2( &r_u->devicepath, devicepath, UNI_STR_DBLTERMINATE );
+	TALLOC_FREE(devicepath);
 	r_u->needed = r_u->devicepath.uni_str_len;
 
 	return WERR_OK;

Modified: branches/SAMBA_3_0_26/source/rpc_server/srv_ntsvcs_nt.c
===================================================================
--- branches/SAMBA_3_0_26/source/rpc_server/srv_ntsvcs_nt.c	2007-06-29 17:27:59 UTC (rev 23660)
+++ branches/SAMBA_3_0_26/source/rpc_server/srv_ntsvcs_nt.c	2007-06-29 17:40:37 UTC (rev 23661)
@@ -27,13 +27,9 @@
 /********************************************************************
 ********************************************************************/
 
-static char* get_device_path( const char *device )
+static char* get_device_path(TALLOC_CTX *mem_ctx, const char *device )
 {
-	static pstring path;
-
-	pstr_sprintf( path, "ROOT\\Legacy_%s\\0000", device );
-
-	return path;
+	return talloc_asprintf(mem_ctx, "ROOT\\Legacy_%s\\0000", device);
 }
 
 /********************************************************************
@@ -52,16 +48,21 @@
 WERROR _ntsvcs_get_device_list_size( pipes_struct *p, NTSVCS_Q_GET_DEVICE_LIST_SIZE *q_u, NTSVCS_R_GET_DEVICE_LIST_SIZE *r_u )
 {
 	fstring device;
-	const char *devicepath;
+	char *devicepath;
 
 	if ( !q_u->devicename )
 		return WERR_ACCESS_DENIED;
 
 	rpcstr_pull(device, q_u->devicename->buffer, sizeof(device), q_u->devicename->uni_str_len*2, 0);
-	devicepath = get_device_path( device );
 
+	if (!(devicepath = get_device_path(p->mem_ctx, device))) {
+		return WERR_NOMEM;
+	}
+
 	r_u->size = strlen(devicepath) + 2;
 
+	TALLOC_FREE(devicepath);
+
 	return WERR_OK;
 }
 
@@ -72,17 +73,21 @@
 WERROR _ntsvcs_get_device_list( pipes_struct *p, NTSVCS_Q_GET_DEVICE_LIST *q_u, NTSVCS_R_GET_DEVICE_LIST *r_u )
 {
 	fstring device;
-	const char *devicepath;
+	char *devicepath;
 
 	if ( !q_u->devicename )
 		return WERR_ACCESS_DENIED;
 
 	rpcstr_pull(device, q_u->devicename->buffer, sizeof(device), q_u->devicename->uni_str_len*2, 0);
-	devicepath = get_device_path( device );
 
+	if (!(devicepath = get_device_path(p->mem_ctx, device))) {
+		return WERR_NOMEM;
+	}
+
 	/* This has to be DOUBLE NULL terminated */
 
 	init_unistr2( &r_u->devicepath, devicepath, UNI_STR_DBLTERMINATE );
+	TALLOC_FREE(devicepath);
 	r_u->needed = r_u->devicepath.uni_str_len;
 
 	return WERR_OK;



More information about the samba-cvs mailing list