mirror of
https://github.com/samba-team/samba.git
synced 2024-12-22 13:34:15 +03:00
Fix more asprintf warnings and some error path errors.
Jeremy.
This commit is contained in:
parent
1966a947d3
commit
d0eeb9aa8d
@ -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);
|
||||
|
@ -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++) */
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user