From ac080e3184abcc177f9f8e8bf2f3537739b9e8ad Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 2 Oct 2006 12:06:49 +0000 Subject: r19039: Do not segfault in "net ads printer info" when a requested printserver does not exist. Guenther (This used to be commit 359315021df3a4dbfe5142e529e3efdbc49e405c) --- source3/libads/ldap_printer.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'source3/libads') 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); -- cgit