diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2008-12-23 22:12:23 +0100 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2008-12-23 22:12:23 +0100 |
commit | 5c75b65ca15f7c71babd835a45b252fed6534acf (patch) | |
tree | 6b8baa3f5d27c4eafd89fece7deedae30a6ff1fd /source3/printing | |
parent | 86cee0b28c50dd849fe919bbe3faa4deba5275bf (diff) | |
parent | ff26cb4b1c1d0292231e1cfc0490f4be6040d3e3 (diff) | |
download | samba-5c75b65ca15f7c71babd835a45b252fed6534acf.tar.gz samba-5c75b65ca15f7c71babd835a45b252fed6534acf.tar.bz2 samba-5c75b65ca15f7c71babd835a45b252fed6534acf.zip |
Merge branch 'master' of ssh://git.samba.org/data/git/samba
Diffstat (limited to 'source3/printing')
-rw-r--r-- | source3/printing/nt_printing.c | 30 | ||||
-rw-r--r-- | source3/printing/print_generic.c | 4 |
2 files changed, 19 insertions, 15 deletions
diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c index ba1fb4352c..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) { @@ -3381,7 +3381,7 @@ static WERROR nt_printer_unpublish_ads(ADS_STRUCT *ads, NT_PRINTER_INFO_LEVEL *printer) { ADS_STATUS ads_rc; - LDAPMessage *res; + LDAPMessage *res = NULL; char *prt_dn = NULL; DEBUG(5, ("unpublishing printer %s\n", printer->info_2->printername)); @@ -3390,7 +3390,7 @@ static WERROR nt_printer_unpublish_ads(ADS_STRUCT *ads, ads_rc = ads_find_printer_on_server(ads, &res, printer->info_2->sharename, global_myname()); - if (ADS_ERR_OK(ads_rc) && ads_count_replies(ads, res)) { + if (ADS_ERR_OK(ads_rc) && res && ads_count_replies(ads, res)) { prt_dn = ads_get_dn(ads, res); if (!prt_dn) { ads_msgfree(ads, res); @@ -3400,7 +3400,9 @@ static WERROR nt_printer_unpublish_ads(ADS_STRUCT *ads, ads_memfree(ads, prt_dn); } - ads_msgfree(ads, res); + if (res) { + ads_msgfree(ads, res); + } return WERR_OK; } 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; } |