summaryrefslogtreecommitdiff
path: root/source3/printing
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 /source3/printing
parent1966a947d3f8d432d3af5a9c0004e27561ae7f65 (diff)
downloadsamba-d0eeb9aa8db42ed1fc18024614560820354e6dfa.tar.gz
samba-d0eeb9aa8db42ed1fc18024614560820354e6dfa.tar.bz2
samba-d0eeb9aa8db42ed1fc18024614560820354e6dfa.zip
Fix more asprintf warnings and some error path errors.
Jeremy.
Diffstat (limited to 'source3/printing')
-rw-r--r--source3/printing/nt_printing.c22
-rw-r--r--source3/printing/print_generic.c4
2 files changed, 14 insertions, 12 deletions
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;
}