The branch, v3-3-test has been updated via 44ab658b6d80c66f20d80aede7fc7cd2b9a941b1 (commit) from b37c96a4fcf35ba2208078a53bf9484dcd31bd31 (commit)
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-3-test - Log ----------------------------------------------------------------- commit 44ab658b6d80c66f20d80aede7fc7cd2b9a941b1 Author: Jeremy Allison <jer...@jeremy-desktop.(none)> Date: Tue Dec 23 12:10:47 2008 -0800 Fix more asprintf warnings and some error path errors. Jeremy. ----------------------------------------------------------------------- Summary of changes: source/libads/util.c | 12 ++++++++++-- source/locking/posix.c | 13 ++++++------- source/printing/nt_printing.c | 22 +++++++++++----------- source/printing/print_generic.c | 4 +++- source/rpc_server/srv_lsa_hnd.c | 11 +++++++---- source/smbd/fileio.c | 9 ++++++--- source/smbd/seal.c | 3 +-- 7 files changed, 44 insertions(+), 30 deletions(-) Changeset truncated at 500 lines: diff --git a/source/libads/util.c b/source/libads/util.c index d23c36f..1fc0579 100644 --- a/source/libads/util.c +++ b/source/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", server, server_realm); + if (asprintf(&princ, "ldap/%...@%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", server, server_realm); + if (asprintf(&princ, "ldap/%...@%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/source/locking/posix.c b/source/locking/posix.c index 32e1ee9..496be89 100644 --- a/source/locking/posix.c +++ b/source/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/source/printing/nt_printing.c b/source/printing/nt_printing.c index 9c62cd5..0d91836 100644 --- a/source/printing/nt_printing.c +++ b/source/printing/nt_printing.c @@ -3163,7 +3163,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); @@ -3243,6 +3245,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)); @@ -3254,27 +3257,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; } @@ -3285,27 +3284,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/source/printing/print_generic.c b/source/printing/print_generic.c index 2a324fd..db61074 100644 --- a/source/printing/print_generic.c +++ b/source/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/source/rpc_server/srv_lsa_hnd.c b/source/rpc_server/srv_lsa_hnd.c index 377ed50..839833c 100644 --- a/source/rpc_server/srv_lsa_hnd.c +++ b/source/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/source/smbd/fileio.c b/source/smbd/fileio.c index 60aeeef..e67f926 100644 --- a/source/smbd/fileio.c +++ b/source/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/source/smbd/seal.c b/source/smbd/seal.c index e9dc46a..ea67a1f 100644 --- a/source/smbd/seal.c +++ b/source/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", service, name); - if (host_princ_s == NULL) { + if (asprintf(&host_princ_s, "%...@%s", service, name) == -1) { return NT_STATUS_NO_MEMORY; } -- Samba Shared Repository