svn commit: samba r26453 - in branches/SAMBA_4_0/source: client lib/registry/tools lib/smbreadline torture torture/rpc

kai at samba.org kai at samba.org
Fri Dec 14 14:04:57 GMT 2007


Author: kai
Date: 2007-12-14 14:04:56 +0000 (Fri, 14 Dec 2007)
New Revision: 26453

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

Log:
Janitorial: Don't use a static char[] in smb_readline_replacement.

Fix up callers to free the memory returned, as that is needed if we use the
original readline function as well.


Modified:
   branches/SAMBA_4_0/source/client/client.c
   branches/SAMBA_4_0/source/lib/registry/tools/regshell.c
   branches/SAMBA_4_0/source/lib/smbreadline/smbreadline.c
   branches/SAMBA_4_0/source/torture/rpc/samr.c
   branches/SAMBA_4_0/source/torture/smbtorture.c


Changeset:
Modified: branches/SAMBA_4_0/source/client/client.c
===================================================================
--- branches/SAMBA_4_0/source/client/client.c	2007-12-14 10:46:35 UTC (rev 26452)
+++ branches/SAMBA_4_0/source/client/client.c	2007-12-14 14:04:56 UTC (rev 26453)
@@ -2997,16 +2997,18 @@
 		char *the_prompt = talloc_asprintf(ctx, "smb: %s> ", ctx->remote_cur_dir);
 		char *cline = smb_readline(the_prompt, readline_callback, completion_fn);
 		talloc_free(the_prompt);
-			
+
 		if (!cline) break;
-		
+
 		/* special case - first char is ! */
 		if (*cline == '!') {
 			system(cline + 1);
 			continue;
 		}
 
-		rc |= process_command_string(ctx, cline); 
+		rc |= process_command_string(ctx, cline);
+		free(cline);
+
 	}
 
 	return rc;

Modified: branches/SAMBA_4_0/source/lib/registry/tools/regshell.c
===================================================================
--- branches/SAMBA_4_0/source/lib/registry/tools/regshell.c	2007-12-14 10:46:35 UTC (rev 26452)
+++ branches/SAMBA_4_0/source/lib/registry/tools/regshell.c	2007-12-14 14:04:56 UTC (rev 26453)
@@ -546,12 +546,16 @@
 							   via readline :-( */
 		line = smb_readline(prompt, NULL, reg_completion);
 
-		if (line == NULL)
+		if (line == NULL) {
+			free(prompt);
 			break;
+		}
 
 		if (line[0] != '\n') {
 			ret = W_ERROR_IS_OK(process_cmd(ctx, line));
 		}
+		free(line);
+		free(prompt);
 	}
 	talloc_free(ctx);
 

Modified: branches/SAMBA_4_0/source/lib/smbreadline/smbreadline.c
===================================================================
--- branches/SAMBA_4_0/source/lib/smbreadline/smbreadline.c	2007-12-14 10:46:35 UTC (rev 26452)
+++ branches/SAMBA_4_0/source/lib/smbreadline/smbreadline.c	2007-12-14 14:04:56 UTC (rev 26453)
@@ -77,13 +77,18 @@
 				      char **(completion_fn)(const char *text, int start, int end))
 {
 	fd_set fds;
-	static char line[1024];
+	char *line;
 	struct timeval timeout;
 	int fd = STDIN_FILENO;
 	char *ret;
 
 	do_debug("%s", prompt);
 
+	line = (char *)malloc(BUFSIZ);
+	if (!line) {
+		return NULL;
+	}
+
 	while (1) {
 		timeout.tv_sec = 5;
 		timeout.tv_usec = 0;
@@ -92,7 +97,7 @@
 		FD_SET(fd,&fds);
 
 		if (sys_select_intr(fd+1,&fds,NULL,NULL,&timeout) == 1) {
-			ret = x_fgets(line, sizeof(line), x_stdin);
+			ret = x_fgets(line, BUFSIZ, x_stdin);
 			return ret;
 		}
 		if (callback)

Modified: branches/SAMBA_4_0/source/torture/rpc/samr.c
===================================================================
--- branches/SAMBA_4_0/source/torture/rpc/samr.c	2007-12-14 10:46:35 UTC (rev 26452)
+++ branches/SAMBA_4_0/source/torture/rpc/samr.c	2007-12-14 14:04:56 UTC (rev 26453)
@@ -824,6 +824,7 @@
 		    case ALIASINFONAME: init_lsa_String(&r.in.info->name,TEST_ALIASNAME); break;
 		    case ALIASINFODESCRIPTION: init_lsa_String(&r.in.info->description,
 				"Test Description, should test I18N as well"); break;
+		    case ALIASINFOALL: printf("ALIASINFOALL ignored\n"); break;
 		}
 
 		status = dcerpc_samr_SetAliasInfo(p, tctx, &r);

Modified: branches/SAMBA_4_0/source/torture/smbtorture.c
===================================================================
--- branches/SAMBA_4_0/source/torture/smbtorture.c	2007-12-14 10:46:35 UTC (rev 26452)
+++ branches/SAMBA_4_0/source/torture/smbtorture.c	2007-12-14 14:04:56 UTC (rev 26453)
@@ -500,6 +500,7 @@
 				run_test(tctx, argv[1]);
 			}
 		}
+		free(cline);
 	}
 }
 



More information about the samba-cvs mailing list