[SCM] Samba Shared Repository - branch v3-3-test updated - release-3-2-0pre2-4760-gcfee202

Jeremy Allison jra at samba.org
Thu Jan 1 00:17:47 GMT 2009


The branch, v3-3-test has been updated
       via  cfee202547a536a54284a14732df2e48eef99952 (commit)
      from  3367acd7fac7758ef5eb027bcd8bcbfbb3f3c0fd (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-3-test


- Log -----------------------------------------------------------------
commit cfee202547a536a54284a14732df2e48eef99952
Author: Jeremy Allison <jra at samba.org>
Date:   Wed Dec 31 16:16:52 2008 -0800

    Fix more asprintf and "ignoring return code" warnings from gcc 4.3.
    Jeremy.

-----------------------------------------------------------------------

Summary of changes:
 source/client/client.c           |   60 +++++++++++++++++------------
 source/libsmb/passchange.c       |   78 +++++++++++++++++++++++++-------------
 source/script/mkbuildoptions.awk |   14 ++++---
 source/winbindd/winbindd_ads.c   |    5 ++-
 source/winbindd/winbindd_cache.c |    4 +-
 5 files changed, 103 insertions(+), 58 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source/client/client.c b/source/client/client.c
index d05a82a..5e3b1a9 100644
--- a/source/client/client.c
+++ b/source/client/client.c
@@ -364,7 +364,7 @@ static int do_cd(const char *new_dir)
 
 	/* Ensure cur_dir ends in a DIRSEP */
 	if ((new_cd[0] != '\0') && (*(new_cd+strlen(new_cd)-1) != CLI_DIRSEP_CHAR)) {
-		new_cd = talloc_asprintf_append(new_cd, CLI_DIRSEP_STR);
+		new_cd = talloc_asprintf_append(new_cd, "%s", CLI_DIRSEP_STR);
 		if (!new_cd) {
 			goto out;
 		}
@@ -871,7 +871,7 @@ static int cmd_dir(void)
 		if (*buf == CLI_DIRSEP_CHAR) {
 			mask = talloc_strdup(ctx, buf);
 		} else {
-			mask = talloc_asprintf_append(mask, buf);
+			mask = talloc_asprintf_append(mask, "%s", buf);
 		}
 	} else {
 		mask = talloc_asprintf_append(mask, "*");
@@ -912,7 +912,7 @@ static int cmd_du(void)
 		return 1;
 	}
 	if ((mask[0] != '\0') && (mask[strlen(mask)-1]!=CLI_DIRSEP_CHAR)) {
-		mask = talloc_asprintf_append(mask, CLI_DIRSEP_STR);
+		mask = talloc_asprintf_append(mask, "%s", CLI_DIRSEP_STR);
 		if (!mask) {
 			return 1;
 		}
@@ -923,7 +923,7 @@ static int cmd_du(void)
 		if (*buf == CLI_DIRSEP_CHAR) {
 			mask = talloc_strdup(ctx, buf);
 		} else {
-			mask = talloc_asprintf_append(mask, buf);
+			mask = talloc_asprintf_append(mask, "%s", buf);
 		}
 	} else {
 		mask = talloc_strdup(ctx, "*");
@@ -1107,7 +1107,7 @@ static int cmd_get(void)
 		d_printf("get <filename> [localname]\n");
 		return 1;
 	}
-	rname = talloc_asprintf_append(rname, fname);
+	rname = talloc_asprintf_append(rname, "%s", fname);
 	if (!rname) {
 		return 1;
 	}
@@ -1223,7 +1223,10 @@ static void do_mget(file_info *finfo, const char *dir)
 	}
 
 	do_list(mget_mask, aSYSTEM | aHIDDEN | aDIR,do_mget,false, true);
-	chdir("..");
+	if (chdir("..") == -1) {
+		d_printf("do_mget: failed to chdir to .. (error %s)\n",
+			strerror(errno) );
+	}
 	client_set_cur_dir(saved_curdir);
 	TALLOC_FREE(mget_mask);
 	TALLOC_FREE(saved_curdir);
@@ -1266,7 +1269,7 @@ static int cmd_more(void)
 		unlink(lname);
 		return 1;
 	}
-	rname = talloc_asprintf_append(rname, fname);
+	rname = talloc_asprintf_append(rname, "%s", fname);
 	if (!rname) {
 		return 1;
 	}
@@ -1286,7 +1289,10 @@ static int cmd_more(void)
 	if (!pager_cmd) {
 		return 1;
 	}
-	system(pager_cmd);
+	if (system(pager_cmd) == -1) {
+		d_printf("system command '%s' returned -1\n",
+			pager_cmd);
+	}
 	unlink(lname);
 
 	return rc;
@@ -1318,7 +1324,7 @@ static int cmd_mget(void)
 			mget_mask = talloc_strdup(ctx, buf);
 		} else {
 			mget_mask = talloc_asprintf_append(mget_mask,
-							buf);
+							"%s", buf);
 		}
 		if (!mget_mask) {
 			return 1;
@@ -1414,7 +1420,7 @@ static int cmd_mkdir(void)
 		}
 		return 1;
 	}
-	mask = talloc_asprintf_append(mask, buf);
+	mask = talloc_asprintf_append(mask, "%s", buf);
 	if (!mask) {
 		return 1;
 	}
@@ -1443,14 +1449,14 @@ static int cmd_mkdir(void)
 		trim_char(ddir,'.','\0');
 		p = strtok_r(ddir, "/\\", &saveptr);
 		while (p) {
-			ddir2 = talloc_asprintf_append(ddir2, p);
+			ddir2 = talloc_asprintf_append(ddir2, "%s", p);
 			if (!ddir2) {
 				return 1;
 			}
 			if (!cli_chkpath(targetcli, ddir2)) {
 				do_mkdir(ddir2);
 			}
-			ddir2 = talloc_asprintf_append(ddir2, CLI_DIRSEP_STR);
+			ddir2 = talloc_asprintf_append(ddir2, "%s", CLI_DIRSEP_STR);
 			if (!ddir2) {
 				return 1;
 			}
@@ -1482,7 +1488,7 @@ static int cmd_altname(void)
 		d_printf("altname <file>\n");
 		return 1;
 	}
-	name = talloc_asprintf_append(name, buf);
+	name = talloc_asprintf_append(name, "%s", buf);
 	if (!name) {
 		return 1;
 	}
@@ -1566,7 +1572,7 @@ static int cmd_allinfo(void)
 		d_printf("allinfo <file>\n");
 		return 1;
 	}
-	name = talloc_asprintf_append(name, buf);
+	name = talloc_asprintf_append(name, "%s", buf);
 	if (!name) {
 		return 1;
 	}
@@ -1733,9 +1739,9 @@ static int cmd_put(void)
 	}
 
 	if (next_token_talloc(ctx, &cmd_ptr,&buf,NULL)) {
-		rname = talloc_asprintf_append(rname, buf);
+		rname = talloc_asprintf_append(rname, "%s", buf);
 	} else {
-		rname = talloc_asprintf_append(rname, lname);
+		rname = talloc_asprintf_append(rname, "%s", lname);
 	}
 	if (!rname) {
 		return 1;
@@ -2132,7 +2138,7 @@ static int cmd_del(void)
 		d_printf("del <filename>\n");
 		return 1;
 	}
-	mask = talloc_asprintf_append(mask, buf);
+	mask = talloc_asprintf_append(mask, "%s", buf);
 	if (!mask) {
 		return 1;
 	}
@@ -3493,7 +3499,10 @@ static int cmd_lcd(void)
 	char *d;
 
 	if (next_token_talloc(ctx, &cmd_ptr,&buf,NULL)) {
-		chdir(buf);
+		if (chdir(buf) == -1) {
+			d_printf("chdir to %s failed (%s)\n",
+				buf, strerror(errno));
+		}
 	}
 	d = TALLOC_ARRAY(ctx, char, PATH_MAX+1);
 	if (!d) {
@@ -3524,7 +3533,7 @@ static int cmd_reget(void)
 		d_printf("reget <filename>\n");
 		return 1;
 	}
-	remote_name = talloc_asprintf_append(remote_name, fname);
+	remote_name = talloc_asprintf_append(remote_name, "%s", fname);
 	if (!remote_name) {
 		return 1;
 	}
@@ -3571,10 +3580,10 @@ static int cmd_reput(void)
 
 	if (next_token_talloc(ctx, &cmd_ptr, &buf, NULL)) {
 		remote_name = talloc_asprintf_append(remote_name,
-						buf);
+						"%s", buf);
 	} else {
 		remote_name = talloc_asprintf_append(remote_name,
-						local_name);
+						"%s", local_name);
 	}
 	if (!remote_name) {
 		return 1;
@@ -4108,13 +4117,13 @@ static void completion_remote_filter(const char *mnt,
 				TALLOC_FREE(ctx);
 				return;
 			}
-			tmp = talloc_asprintf_append(tmp, f->name);
+			tmp = talloc_asprintf_append(tmp, "%s", f->name);
 			if (!tmp) {
 				TALLOC_FREE(ctx);
 				return;
 			}
 			if (f->mode & aDIR) {
-				tmp = talloc_asprintf_append(tmp, CLI_DIRSEP_STR);
+				tmp = talloc_asprintf_append(tmp, "%s", CLI_DIRSEP_STR);
 			}
 			if (!tmp) {
 				TALLOC_FREE(ctx);
@@ -4459,7 +4468,10 @@ static int process_stdin(void)
 
 		/* special case - first char is ! */
 		if (*line == '!') {
-			system(line + 1);
+			if (system(line + 1) == -1) {
+				d_printf("system() command %s failed.\n",
+					line+1);
+			}
 			SAFE_FREE(line);
 			TALLOC_FREE(frame);
 			continue;
diff --git a/source/libsmb/passchange.c b/source/libsmb/passchange.c
index c8a4406..c7140a9 100644
--- a/source/libsmb/passchange.c
+++ b/source/libsmb/passchange.c
@@ -38,8 +38,10 @@ NTSTATUS remote_password_change(const char *remote_machine, const char *user_nam
 	*err_str = NULL;
 
 	if(!resolve_name( remote_machine, &ss, 0x20)) {
-		asprintf(err_str, "Unable to find an IP address for machine "
-			 "%s.\n", remote_machine);
+		if (asprintf(err_str, "Unable to find an IP address for machine "
+			 "%s.\n", remote_machine) == -1) {
+			*err_str = NULL;
+		}
 		return NT_STATUS_UNSUCCESSFUL;
 	}
  
@@ -50,9 +52,11 @@ NTSTATUS remote_password_change(const char *remote_machine, const char *user_nam
 
 	result = cli_connect(cli, remote_machine, &ss);
 	if (!NT_STATUS_IS_OK(result)) {
-		asprintf(err_str, "Unable to connect to SMB server on "
+		if (asprintf(err_str, "Unable to connect to SMB server on "
 			 "machine %s. Error was : %s.\n",
-			 remote_machine, nt_errstr(result));
+			 remote_machine, nt_errstr(result))==-1) {
+			*err_str = NULL;
+		}
 		cli_shutdown(cli);
 		return result;
 	}
@@ -61,9 +65,11 @@ NTSTATUS remote_password_change(const char *remote_machine, const char *user_nam
 	make_nmb_name(&called , remote_machine, 0x20);
 	
 	if (!cli_session_request(cli, &calling, &called)) {
-		asprintf(err_str, "machine %s rejected the session setup. "
+		if (asprintf(err_str, "machine %s rejected the session setup. "
 			 "Error was : %s.\n",
-			 remote_machine, cli_errstr(cli) );
+			 remote_machine, cli_errstr(cli)) == -1) {
+			*err_str = NULL;
+		}
 		result = cli_nt_error(cli);
 		cli_shutdown(cli);
 		return result;
@@ -72,9 +78,11 @@ NTSTATUS remote_password_change(const char *remote_machine, const char *user_nam
 	cli->protocol = PROTOCOL_NT1;
 
 	if (!cli_negprot(cli)) {
-		asprintf(err_str, "machine %s rejected the negotiate "
+		if (asprintf(err_str, "machine %s rejected the negotiate "
 			 "protocol. Error was : %s.\n",        
-			 remote_machine, cli_errstr(cli) );
+			 remote_machine, cli_errstr(cli)) == -1) {
+			*err_str = NULL;
+		}
 		result = cli_nt_error(cli);
 		cli_shutdown(cli);
 		return result;
@@ -95,8 +103,10 @@ NTSTATUS remote_password_change(const char *remote_machine, const char *user_nam
 
 		if (!NT_STATUS_EQUAL(result, NT_STATUS_PASSWORD_MUST_CHANGE) &&
 		    !NT_STATUS_EQUAL(result, NT_STATUS_PASSWORD_EXPIRED)) {
-			asprintf(err_str, "Could not connect to machine %s: "
-				 "%s\n", remote_machine, cli_errstr(cli));
+			if (asprintf(err_str, "Could not connect to machine %s: "
+				 "%s\n", remote_machine, cli_errstr(cli)) == -1) {
+				*err_str = NULL;
+			}
 			cli_shutdown(cli);
 			return result;
 		}
@@ -112,9 +122,11 @@ NTSTATUS remote_password_change(const char *remote_machine, const char *user_nam
 		result = cli_session_setup(cli, "", "", 0, "", 0, "");
 
 		if (!NT_STATUS_IS_OK(result)) {
-			asprintf(err_str, "machine %s rejected the session "
+			if (asprintf(err_str, "machine %s rejected the session "
 				 "setup. Error was : %s.\n",        
-				 remote_machine, cli_errstr(cli) );
+				 remote_machine, cli_errstr(cli)) == -1) {
+				*err_str = NULL;
+			}
 			cli_shutdown(cli);
 			return result;
 		}
@@ -125,9 +137,11 @@ NTSTATUS remote_password_change(const char *remote_machine, const char *user_nam
 	}
 
 	if (!cli_send_tconX(cli, "IPC$", "IPC", "", 1)) {
-		asprintf(err_str, "machine %s rejected the tconX on the IPC$ "
+		if (asprintf(err_str, "machine %s rejected the tconX on the IPC$ "
 			 "share. Error was : %s.\n",
-			 remote_machine, cli_errstr(cli) );
+			 remote_machine, cli_errstr(cli)) == -1) {
+			*err_str = NULL;
+		}
 		result = cli_nt_error(cli);
 		cli_shutdown(cli);
 		return result;
@@ -160,18 +174,22 @@ NTSTATUS remote_password_change(const char *remote_machine, const char *user_nam
 		if (lp_client_lanman_auth()) {
 			/* Use the old RAP method. */
 			if (!cli_oem_change_password(cli, user_name, new_passwd, old_passwd)) {
-				asprintf(err_str, "machine %s rejected the "
+				if (asprintf(err_str, "machine %s rejected the "
 					 "password change: Error was : %s.\n",
-					 remote_machine, cli_errstr(cli) );
+					 remote_machine, cli_errstr(cli)) == -1) {
+					*err_str = NULL;
+				}
 				result = cli_nt_error(cli);
 				cli_shutdown(cli);
 				return result;
 			}
 		} else {
-			asprintf(err_str, "SAMR connection to machine %s "
+			if (asprintf(err_str, "SAMR connection to machine %s "
 				 "failed. Error was %s, but LANMAN password "
 				 "changed are disabled\n",
-				 nt_errstr(result), remote_machine);
+				 nt_errstr(result), remote_machine) == -1) {
+				*err_str = NULL;
+			}
 			result = cli_nt_error(cli);
 			cli_shutdown(cli);
 			return result;
@@ -189,9 +207,11 @@ NTSTATUS remote_password_change(const char *remote_machine, const char *user_nam
 		     || NT_STATUS_EQUAL(result, NT_STATUS_UNSUCCESSFUL))) {
 		/* it failed, but for reasons such as wrong password, too short etc ... */
 		
-		asprintf(err_str, "machine %s rejected the password change: "
+		if (asprintf(err_str, "machine %s rejected the password change: "
 			 "Error was : %s.\n",
-			 remote_machine, get_friendly_nt_error_msg(result));
+			 remote_machine, get_friendly_nt_error_msg(result)) == -1) {
+			*err_str = NULL;
+		}
 		cli_shutdown(cli);
 		return result;
 	}
@@ -220,10 +240,12 @@ NTSTATUS remote_password_change(const char *remote_machine, const char *user_nam
 		      || NT_STATUS_EQUAL(result, NT_STATUS_UNSUCCESSFUL))) {
 			/* it failed, but again it was due to things like new password too short */
 
-			asprintf(err_str, "machine %s rejected the "
+			if (asprintf(err_str, "machine %s rejected the "
 				 "(anonymous) password change: Error was : "
 				 "%s.\n", remote_machine,
-				 get_friendly_nt_error_msg(result));
+				 get_friendly_nt_error_msg(result)) == -1) {
+				*err_str = NULL;
+			}
 			cli_shutdown(cli);
 			return result;
 		}
@@ -239,17 +261,21 @@ NTSTATUS remote_password_change(const char *remote_machine, const char *user_nam
 				cli_shutdown(cli);
 				return NT_STATUS_OK;
 			}
-			asprintf(err_str, "machine %s rejected the password "
+			if (asprintf(err_str, "machine %s rejected the password "
 				 "change: Error was : %s.\n",
-				 remote_machine, cli_errstr(cli) );
+				 remote_machine, cli_errstr(cli)) == -1) {
+				*err_str = NULL;
+			}
 			result = cli_nt_error(cli);
 			cli_shutdown(cli);
 			return result;
 		} else {
-			asprintf(err_str, "SAMR connection to machine %s "
+			if (asprintf(err_str, "SAMR connection to machine %s "
 				 "failed. Error was %s, but LANMAN password "
 				 "changed are disabled\n",
-				nt_errstr(result), remote_machine);
+				nt_errstr(result), remote_machine) == -1) {
+				*err_str = NULL;
+			}
 			cli_shutdown(cli);
 			return NT_STATUS_UNSUCCESSFUL;
 		}
diff --git a/source/script/mkbuildoptions.awk b/source/script/mkbuildoptions.awk
index 02562cf..a1e5d85 100644
--- a/source/script/mkbuildoptions.awk
+++ b/source/script/mkbuildoptions.awk
@@ -23,29 +23,31 @@ BEGIN {
 	print "#include \"build_env.h\"";
 	print "#include \"dynconfig.h\"";
 	print "";
-	print "static void output(bool screen, const char *format, ...) PRINTF_ATTRIBUTE(2,3);";
+	print "static int output(bool screen, const char *format, ...) PRINTF_ATTRIBUTE(2,3);";
 	print "void build_options(bool screen);";
 	print "";
 	print "";
 	print "/****************************************************************************";
 	print "helper function for build_options";
 	print "****************************************************************************/";
-	print "static void output(bool screen, const char *format, ...)";
+	print "static int output(bool screen, const char *format, ...)";
 	print "{";
-	print "       char *ptr;";
+	print "       char *ptr = NULL;";
+	print "       int ret = 0;";
 	print "       va_list ap;";
 	print "       ";
 	print "       va_start(ap, format);";
-	print "       vasprintf(&ptr,format,ap);";
+	print "       ret = vasprintf(&ptr,format,ap);";
 	print "       va_end(ap);";
 	print "";
 	print "       if (screen) {";
-	print "              d_printf(\"%s\", ptr);";
+	print "              d_printf(\"%s\", ptr ? ptr : \"\");";
 	print "       } else {";
-	print "	       DEBUG(4,(\"%s\", ptr));";
+	print "	       DEBUG(4,(\"%s\", ptr ? ptr : \"\"));";
 	print "       }";
 	print "       ";
 	print "       SAFE_FREE(ptr);";
+	print "       return ret;";
 	print "}";
 	print "";
 	print "/****************************************************************************";
diff --git a/source/winbindd/winbindd_ads.c b/source/winbindd/winbindd_ads.c
index 5c7d491..a508682 100644
--- a/source/winbindd/winbindd_ads.c
+++ b/source/winbindd/winbindd_ads.c
@@ -525,7 +525,10 @@ static NTSTATUS query_user(struct winbindd_domain *domain,
 	}
 
 	sidstr = sid_binstring(sid);
-	asprintf(&ldap_exp, "(objectSid=%s)", sidstr);
+	if (asprintf(&ldap_exp, "(objectSid=%s)", sidstr) == -1) {
+		status = NT_STATUS_NO_MEMORY;
+		goto done;
+	}
 	rc = ads_search_retry(ads, &msg, ldap_exp, attrs);
 	free(ldap_exp);
 	free(sidstr);
diff --git a/source/winbindd/winbindd_cache.c b/source/winbindd/winbindd_cache.c
index 2f4a6ff..1ae7966 100644
--- a/source/winbindd/winbindd_cache.c
+++ b/source/winbindd/winbindd_cache.c
@@ -3852,7 +3852,9 @@ static TDB_DATA make_tdc_key( const char *domain_name )
 	}
 	       
 		
-	asprintf( &keystr, "TRUSTDOMCACHE/%s", domain_name );
+	if (asprintf( &keystr, "TRUSTDOMCACHE/%s", domain_name ) == -1) {
+		return key;
+	}
 	key = string_term_tdb_data(keystr);
 	
 	return key;	


-- 
Samba Shared Repository


More information about the samba-cvs mailing list