Deleted Added
full compact
sm_resolve.c (182352) sm_resolve.c (223067)
1/*
1/*
2 * Copyright (c) 2000-2004 Sendmail, Inc. and its suppliers.
2 * Copyright (c) 2000-2004, 2010 Sendmail, Inc. and its suppliers.
3 * All rights reserved.
4 *
5 * By using this file, you agree to the terms and conditions set
6 * forth in the LICENSE file which can be found at the top level of
7 * the sendmail distribution.
8 *
9 */
10

--- 28 unchanged lines hidden (view full) ---

39 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
40 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
41 * SUCH DAMAGE.
42 */
43
44#include <sendmail.h>
45#if DNSMAP
46# if NAMED_BIND
3 * All rights reserved.
4 *
5 * By using this file, you agree to the terms and conditions set
6 * forth in the LICENSE file which can be found at the top level of
7 * the sendmail distribution.
8 *
9 */
10

--- 28 unchanged lines hidden (view full) ---

39 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
40 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
41 * SUCH DAMAGE.
42 */
43
44#include <sendmail.h>
45#if DNSMAP
46# if NAMED_BIND
47# if NETINET
48# include <netinet/in_systm.h>
49# include <netinet/ip.h>
50# endif /* NETINET */
47# include "sm_resolve.h"
48
51# include "sm_resolve.h"
52
49SM_RCSID("$Id: sm_resolve.c,v 8.36 2008/02/11 23:04:16 ca Exp $")
53SM_RCSID("$Id: sm_resolve.c,v 8.39 2010/06/29 15:35:33 ca Exp $")
50
51static struct stot
52{
53 const char *st_name;
54 int st_type;
55} stot[] =
56{
57# if NETINET

--- 331 unchanged lines hidden (view full) ---

389 time_t retrans;
390 int retry;
391{
392 int len;
393 unsigned long old_options = 0;
394 time_t save_retrans = 0;
395 int save_retry = 0;
396 DNS_REPLY_T *r = NULL;
54
55static struct stot
56{
57 const char *st_name;
58 int st_type;
59} stot[] =
60{
61# if NETINET

--- 331 unchanged lines hidden (view full) ---

393 time_t retrans;
394 int retry;
395{
396 int len;
397 unsigned long old_options = 0;
398 time_t save_retrans = 0;
399 int save_retry = 0;
400 DNS_REPLY_T *r = NULL;
397 unsigned char reply[1024];
401 querybuf reply_buf;
402 unsigned char *reply;
398
403
404#define SMRBSIZE sizeof(reply_buf)
405#ifndef IP_MAXPACKET
406# define IP_MAXPACKET 65535
407#endif
408
399 if (tTd(8, 16))
400 {
401 old_options = _res.options;
402 _res.options |= RES_DEBUG;
403 sm_dprintf("dns_lookup(%s, %d, %s)\n", domain,
404 rr_class, dns_type_to_string(rr_type));
405 }
406 if (retrans > 0)
407 {
408 save_retrans = _res.retrans;
409 _res.retrans = retrans;
410 }
411 if (retry > 0)
412 {
413 save_retry = _res.retry;
414 _res.retry = retry;
415 }
416 errno = 0;
417 SM_SET_H_ERRNO(0);
409 if (tTd(8, 16))
410 {
411 old_options = _res.options;
412 _res.options |= RES_DEBUG;
413 sm_dprintf("dns_lookup(%s, %d, %s)\n", domain,
414 rr_class, dns_type_to_string(rr_type));
415 }
416 if (retrans > 0)
417 {
418 save_retrans = _res.retrans;
419 _res.retrans = retrans;
420 }
421 if (retry > 0)
422 {
423 save_retry = _res.retry;
424 _res.retry = retry;
425 }
426 errno = 0;
427 SM_SET_H_ERRNO(0);
418 len = res_search(domain, rr_class, rr_type, reply, sizeof(reply));
428 reply = (unsigned char *)&reply_buf;
429 len = res_search(domain, rr_class, rr_type, reply, SMRBSIZE);
430 if (len >= SMRBSIZE)
431 {
432 if (len >= IP_MAXPACKET)
433 {
434 if (tTd(8, 4))
435 sm_dprintf("dns_lookup: domain=%s, length=%d, default_size=%d, max=%d, status=response too long\n",
436 domain, len, (int) SMRBSIZE,
437 IP_MAXPACKET);
438 }
439 else
440 {
441 if (tTd(8, 6))
442 sm_dprintf("dns_lookup: domain=%s, length=%d, default_size=%d, max=%d, status=response longer than default size, resizing\n",
443 domain, len, (int) SMRBSIZE,
444 IP_MAXPACKET);
445 reply = (unsigned char *)sm_malloc(IP_MAXPACKET);
446 if (reply == NULL)
447 SM_SET_H_ERRNO(TRY_AGAIN);
448 else
449 len = res_search(domain, rr_class, rr_type,
450 reply, IP_MAXPACKET);
451 }
452 }
419 if (tTd(8, 16))
420 {
421 _res.options = old_options;
422 sm_dprintf("dns_lookup(%s, %d, %s) --> %d\n",
423 domain, rr_class, dns_type_to_string(rr_type), len);
424 }
453 if (tTd(8, 16))
454 {
455 _res.options = old_options;
456 sm_dprintf("dns_lookup(%s, %d, %s) --> %d\n",
457 domain, rr_class, dns_type_to_string(rr_type), len);
458 }
425 if (len >= 0)
459 if (len >= 0 && len < IP_MAXPACKET && reply != NULL)
426 r = parse_dns_reply(reply, len);
460 r = parse_dns_reply(reply, len);
461 if (reply != (unsigned char *)&reply_buf && reply != NULL)
462 {
463 sm_free(reply);
464 reply = NULL;
465 }
427 if (retrans > 0)
428 _res.retrans = save_retrans;
429 if (retry > 0)
430 _res.retry = save_retry;
431 return r;
432}
433
434# if 0

--- 22 unchanged lines hidden ---
466 if (retrans > 0)
467 _res.retrans = save_retrans;
468 if (retry > 0)
469 _res.retry = save_retry;
470 return r;
471}
472
473# if 0

--- 22 unchanged lines hidden ---