summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jeremy@jeremy-desktop.(none)>2008-12-23 12:11:12 -0800
committerJeremy Allison <jeremy@jeremy-desktop.(none)>2008-12-23 12:11:12 -0800
commitd0eeb9aa8db42ed1fc18024614560820354e6dfa (patch)
tree4b981ba4aa23fe1a9d53139a135018cbbd5871b5
parent1966a947d3f8d432d3af5a9c0004e27561ae7f65 (diff)
downloadsamba-d0eeb9aa8db42ed1fc18024614560820354e6dfa.tar.gz
samba-d0eeb9aa8db42ed1fc18024614560820354e6dfa.tar.bz2
samba-d0eeb9aa8db42ed1fc18024614560820354e6dfa.zip
Fix more asprintf warnings and some error path errors.
Jeremy.
-rw-r--r--source3/libads/util.c12
-rw-r--r--source3/locking/posix.c13
-rw-r--r--source3/printing/nt_printing.c22
-rw-r--r--source3/printing/print_generic.c4
-rw-r--r--source3/rpc_server/srv_lsa_hnd.c11
-rw-r--r--source3/smbd/fileio.c9
-rw-r--r--source3/smbd/seal.c3
7 files changed, 44 insertions, 30 deletions
diff --git a/source3/libads/util.c b/source3/libads/util.c
index 9866a15285..2c7ccfebd6 100644
--- a/source3/libads/util.c
+++ b/source3/libads/util.c
@@ -71,7 +71,11 @@ ADS_STATUS ads_guess_service_principal(ADS_STRUCT *ads,
strlower_m(server);
strupper_m(server_realm);
- asprintf(&princ, "ldap/%s@%s", server, server_realm);
+ if (asprintf(&princ, "ldap/%s@%s", server, server_realm) == -1) {
+ SAFE_FREE(server);
+ SAFE_FREE(server_realm);
+ return ADS_ERROR(LDAP_NO_MEMORY);
+ }
SAFE_FREE(server);
SAFE_FREE(server_realm);
@@ -93,7 +97,11 @@ ADS_STATUS ads_guess_service_principal(ADS_STRUCT *ads,
strlower_m(server);
strupper_m(server_realm);
- asprintf(&princ, "ldap/%s@%s", server, server_realm);
+ if (asprintf(&princ, "ldap/%s@%s", server, server_realm) == -1) {
+ SAFE_FREE(server);
+ SAFE_FREE(server_realm);
+ return ADS_ERROR(LDAP_NO_MEMORY);
+ }
SAFE_FREE(server);
SAFE_FREE(server_realm);
diff --git a/source3/locking/posix.c b/source3/locking/posix.c
index c036ee597c..9b51c3aa6a 100644
--- a/source3/locking/posix.c
+++ b/source3/locking/posix.c
@@ -909,13 +909,12 @@ new: start=%.0f,size=%.0f\n", (double)l_curr->start, (double)l_curr->size,
*/
char *msg = NULL;
- /* Don't check if alloc succeeds here - we're
- * forcing a core dump anyway. */
-
- asprintf(&msg, "logic flaw in cases: l_curr: start = %.0f, size = %.0f : \
-lock: start = %.0f, size = %.0f", (double)l_curr->start, (double)l_curr->size, (double)lock->start, (double)lock->size );
-
- smb_panic(msg);
+ if (asprintf(&msg, "logic flaw in cases: l_curr: start = %.0f, size = %.0f : \
+lock: start = %.0f, size = %.0f", (double)l_curr->start, (double)l_curr->size, (double)lock->start, (double)lock->size ) != -1) {
+ smb_panic(msg);
+ } else {
+ smb_panic("posix_lock_list");
+ }
}
} /* end for ( l_curr = lhead; l_curr;) */
} /* end for (i=0; i<num_locks && ul_head; i++) */
diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c
index 2b24fdd923..3a81f27ad6 100644
--- a/source3/printing/nt_printing.c
+++ b/source3/printing/nt_printing.c
@@ -3187,7 +3187,9 @@ static bool map_nt_printer_info2_to_dsspooler(NT_PRINTER_INFO_LEVEL_2 *info2)
map_sz_into_ctr(ctr, SPOOL_REG_SERVERNAME, longname);
- asprintf(&allocated_string, "\\\\%s\\%s", longname, info2->sharename);
+ if (asprintf(&allocated_string, "\\\\%s\\%s", longname, info2->sharename) == -1) {
+ return false;
+ }
map_sz_into_ctr(ctr, SPOOL_REG_UNCNAME, allocated_string);
SAFE_FREE(allocated_string);
@@ -3267,6 +3269,7 @@ static WERROR nt_printer_publish_ads(ADS_STRUCT *ads,
struct GUID guid;
WERROR win_rc = WERR_OK;
size_t converted_size;
+ int ret;
DEBUG(5, ("publishing printer %s\n", printer->info_2->printername));
@@ -3278,27 +3281,23 @@ static WERROR nt_printer_publish_ads(ADS_STRUCT *ads,
srv_dn_utf8 = ldap_get_dn((LDAP *)ads->ldap.ld, (LDAPMessage *)res);
if (!srv_dn_utf8) {
- ads_destroy(&ads);
return WERR_SERVER_UNAVAILABLE;
}
ads_msgfree(ads, res);
srv_cn_utf8 = ldap_explode_dn(srv_dn_utf8, 1);
if (!srv_cn_utf8) {
ldap_memfree(srv_dn_utf8);
- ads_destroy(&ads);
return WERR_SERVER_UNAVAILABLE;
}
/* Now convert to CH_UNIX. */
if (!pull_utf8_allocate(&srv_dn, srv_dn_utf8, &converted_size)) {
ldap_memfree(srv_dn_utf8);
ldap_memfree(srv_cn_utf8);
- ads_destroy(&ads);
return WERR_SERVER_UNAVAILABLE;
}
if (!pull_utf8_allocate(&srv_cn_0, srv_cn_utf8[0], &converted_size)) {
ldap_memfree(srv_dn_utf8);
ldap_memfree(srv_cn_utf8);
- ads_destroy(&ads);
SAFE_FREE(srv_dn);
return WERR_SERVER_UNAVAILABLE;
}
@@ -3309,27 +3308,28 @@ static WERROR nt_printer_publish_ads(ADS_STRUCT *ads,
srv_cn_escaped = escape_rdn_val_string_alloc(srv_cn_0);
if (!srv_cn_escaped) {
SAFE_FREE(srv_cn_0);
- ldap_memfree(srv_dn_utf8);
- ads_destroy(&ads);
+ SAFE_FREE(srv_dn);
return WERR_SERVER_UNAVAILABLE;
}
sharename_escaped = escape_rdn_val_string_alloc(printer->info_2->sharename);
if (!sharename_escaped) {
SAFE_FREE(srv_cn_escaped);
SAFE_FREE(srv_cn_0);
- ldap_memfree(srv_dn_utf8);
- ads_destroy(&ads);
+ SAFE_FREE(srv_dn);
return WERR_SERVER_UNAVAILABLE;
}
-
- asprintf(&prt_dn, "cn=%s-%s,%s", srv_cn_escaped, sharename_escaped, srv_dn);
+ ret = asprintf(&prt_dn, "cn=%s-%s,%s", srv_cn_escaped, sharename_escaped, srv_dn);
SAFE_FREE(srv_dn);
SAFE_FREE(srv_cn_0);
SAFE_FREE(srv_cn_escaped);
SAFE_FREE(sharename_escaped);
+ if (ret == -1) {
+ return WERR_NOMEM;
+ }
+
/* build the ads mods */
ctx = talloc_init("nt_printer_publish_ads");
if (ctx == NULL) {
diff --git a/source3/printing/print_generic.c b/source3/printing/print_generic.c
index 5806b29206..b789354999 100644
--- a/source3/printing/print_generic.c
+++ b/source3/printing/print_generic.c
@@ -205,7 +205,9 @@ static int generic_job_submit(int snum, struct printjob *pjob)
out:
- chdir(wd);
+ if (chdir(wd) == -1) {
+ smb_panic("chdir failed in generic_job_submit");
+ }
TALLOC_FREE(current_directory);
return ret;
}
diff --git a/source3/rpc_server/srv_lsa_hnd.c b/source3/rpc_server/srv_lsa_hnd.c
index 377ed505b4..839833ce54 100644
--- a/source3/rpc_server/srv_lsa_hnd.c
+++ b/source3/rpc_server/srv_lsa_hnd.c
@@ -54,10 +54,13 @@ bool init_pipe_handle_list(pipes_struct *p, const char *pipe_name)
(is_samr_lsa_pipe(plist->name) && is_samr_lsa_pipe(pipe_name))) {
if (!plist->pipe_handles) {
char *msg;
- asprintf(&msg, "init_pipe_handles: NULL "
- "pipe_handle pointer in pipe %s",
- pipe_name);
- smb_panic(msg);
+ if (asprintf(&msg, "init_pipe_handles: NULL "
+ "pipe_handle pointer in pipe %s",
+ pipe_name) != -1) {
+ smb_panic(msg);
+ } else {
+ smb_panic("init_pipe_handle_list");
+ }
}
hl = plist->pipe_handles;
break;
diff --git a/source3/smbd/fileio.c b/source3/smbd/fileio.c
index 60aeeef1e2..e67f926a04 100644
--- a/source3/smbd/fileio.c
+++ b/source3/smbd/fileio.c
@@ -867,11 +867,14 @@ void set_filelen_write_cache(files_struct *fsp, SMB_OFF_T file_size)
/* The cache *must* have been flushed before we do this. */
if (fsp->wcp->data_size != 0) {
char *msg;
- asprintf(&msg, "set_filelen_write_cache: size change "
+ if (asprintf(&msg, "set_filelen_write_cache: size change "
"on file %s with write cache size = %lu\n",
fsp->fsp_name,
- (unsigned long)fsp->wcp->data_size);
- smb_panic(msg);
+ (unsigned long)fsp->wcp->data_size) != -1) {
+ smb_panic(msg);
+ } else {
+ smb_panic("set_filelen_write_cache");
+ }
}
fsp->wcp->file_size = file_size;
}
diff --git a/source3/smbd/seal.c b/source3/smbd/seal.c
index 3822ee191e..bd4d853885 100644
--- a/source3/smbd/seal.c
+++ b/source3/smbd/seal.c
@@ -128,8 +128,7 @@ static NTSTATUS get_srv_gss_creds(const char *service,
gss_OID_desc nt_hostbased_service =
{10, CONST_DISCARD(char *,"\x2a\x86\x48\x86\xf7\x12\x01\x02\x01\x04")};
- asprintf(&host_princ_s, "%s@%s", service, name);
- if (host_princ_s == NULL) {
+ if (asprintf(&host_princ_s, "%s@%s", service, name) == -1) {
return NT_STATUS_NO_MEMORY;
}