Deleted Added
full compact
ldapclient.c (290931) ldapclient.c (290940)
1/* $OpenBSD: ldapclient.c,v 1.31 2014/11/16 23:24:44 tedu Exp $ */
1/* $OpenBSD: ldapclient.c,v 1.31 2014/11/16 23:24:44 tedu Exp $ */
2/* $FreeBSD: head/usr.sbin/ypldap/ldapclient.c 290931 2015-11-16 16:48:43Z rodrigc $ */
2/* $FreeBSD: head/usr.sbin/ypldap/ldapclient.c 290940 2015-11-16 17:11:11Z rodrigc $ */
3
4/*
5 * Copyright (c) 2008 Alexander Schrijver <aschrijver@openbsd.org>
6 * Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org>
7 *
8 * Permission to use, copy, modify, and distribute this software for any
9 * purpose with or without fee is hereby granted, provided that the above
10 * copyright notice and this permission notice appear in all copies.

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

66{
67 int fd = -1;
68 struct ypldap_addr *p;
69
70 for (p = addr; p != NULL; p = p->next) {
71 char hbuf[NI_MAXHOST], sbuf[NI_MAXSERV];
72 struct sockaddr *sa = (struct sockaddr *)&p->ss;
73
3
4/*
5 * Copyright (c) 2008 Alexander Schrijver <aschrijver@openbsd.org>
6 * Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org>
7 *
8 * Permission to use, copy, modify, and distribute this software for any
9 * purpose with or without fee is hereby granted, provided that the above
10 * copyright notice and this permission notice appear in all copies.

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

66{
67 int fd = -1;
68 struct ypldap_addr *p;
69
70 for (p = addr; p != NULL; p = p->next) {
71 char hbuf[NI_MAXHOST], sbuf[NI_MAXSERV];
72 struct sockaddr *sa = (struct sockaddr *)&p->ss;
73
74 if (getnameinfo(sa, SA_LEN(sa), hbuf, sizeof(hbuf), sbuf,
74 if (getnameinfo(sa, sa->sa_len, hbuf, sizeof(hbuf), sbuf,
75 sizeof(sbuf), NI_NUMERICHOST | NI_NUMERICSERV))
76 errx(1, "could not get numeric hostname");
77
78 if ((fd = socket(sa->sa_family, SOCK_STREAM, 0)) < 0)
79 return NULL;
80
75 sizeof(sbuf), NI_NUMERICHOST | NI_NUMERICSERV))
76 errx(1, "could not get numeric hostname");
77
78 if ((fd = socket(sa->sa_family, SOCK_STREAM, 0)) < 0)
79 return NULL;
80
81 if (connect(fd, sa, SA_LEN(sa)) == 0)
81 if (connect(fd, sa, sa->sa_len) == 0)
82 break;
83
84 warn("connect to %s port %s (%s) failed", hbuf, sbuf, "tcp");
85 close(fd);
86 }
87
88 if (fd == -1)
89 return NULL;

--- 615 unchanged lines hidden ---
82 break;
83
84 warn("connect to %s port %s (%s) failed", hbuf, sbuf, "tcp");
85 close(fd);
86 }
87
88 if (fd == -1)
89 return NULL;

--- 615 unchanged lines hidden ---