diff options
author | Günther Deschner <gd@samba.org> | 2006-10-02 12:06:49 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:15:04 -0500 |
commit | ac080e3184abcc177f9f8e8bf2f3537739b9e8ad (patch) | |
tree | 78e8d94acd628ff2bec5413151219d2e52864ad3 /source3 | |
parent | 6b80d173eda176594cc9cc36511ba62079964cfd (diff) | |
download | samba-ac080e3184abcc177f9f8e8bf2f3537739b9e8ad.tar.gz samba-ac080e3184abcc177f9f8e8bf2f3537739b9e8ad.tar.bz2 samba-ac080e3184abcc177f9f8e8bf2f3537739b9e8ad.zip |
r19039: Do not segfault in "net ads printer info" when a requested printserver
does not exist.
Guenther
(This used to be commit 359315021df3a4dbfe5142e529e3efdbc49e405c)
Diffstat (limited to 'source3')
-rw-r--r-- | source3/libads/ldap_printer.c | 10 | ||||
-rw-r--r-- | source3/utils/net_ads.c | 3 |
2 files changed, 12 insertions, 1 deletions
diff --git a/source3/libads/ldap_printer.c b/source3/libads/ldap_printer.c index 50233140f0..f5168b05af 100644 --- a/source3/libads/ldap_printer.c +++ b/source3/libads/ldap_printer.c @@ -41,8 +41,18 @@ servername)); return status; } + if (ads_count_replies(ads, *res) != 1) { + return ADS_ERROR(LDAP_NO_SUCH_OBJECT); + } srv_dn = ldap_get_dn(ads->ld, *res); + if (srv_dn == NULL) { + return ADS_ERROR(LDAP_NO_MEMORY); + } srv_cn = ldap_explode_dn(srv_dn, 1); + if (srv_cn == NULL) { + ldap_memfree(srv_dn); + return ADS_ERROR(LDAP_INVALID_DN_SYNTAX); + } ads_msgfree(ads, *res); asprintf(&s, "(cn=%s-%s)", srv_cn[0], printer); diff --git a/source3/utils/net_ads.c b/source3/utils/net_ads.c index 2593a59603..53d9f65d6b 100644 --- a/source3/utils/net_ads.c +++ b/source3/utils/net_ads.c @@ -1634,7 +1634,8 @@ static int net_ads_printer_info(int argc, const char **argv) rc = ads_find_printer_on_server(ads, &res, printername, servername); if (!ADS_ERR_OK(rc)) { - d_fprintf(stderr, "ads_find_printer_on_server: %s\n", ads_errstr(rc)); + d_fprintf(stderr, "Server '%s' not found: %s\n", + servername, ads_errstr(rc)); ads_msgfree(ads, res); ads_destroy(&ads); return -1; |