diff options
Diffstat (limited to 'src/gns/nss/nss_gns_query.c')
-rw-r--r-- | src/gns/nss/nss_gns_query.c | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/src/gns/nss/nss_gns_query.c b/src/gns/nss/nss_gns_query.c index 094e25ed5..867ead624 100644 --- a/src/gns/nss/nss_gns_query.c +++ b/src/gns/nss/nss_gns_query.c | |||
@@ -11,7 +11,7 @@ | |||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | */ | 17 | */ |
@@ -48,14 +48,16 @@ gns_resolve_name (int af, | |||
48 | { | 48 | { |
49 | if (-1 == asprintf (&cmd, | 49 | if (-1 == asprintf (&cmd, |
50 | "%s -t AAAA -u %s\n", | 50 | "%s -t AAAA -u %s\n", |
51 | "gnunet-gns -r", name)) | 51 | "gnunet-gns -r", |
52 | name)) | ||
52 | return -1; | 53 | return -1; |
53 | } | 54 | } |
54 | else | 55 | else |
55 | { | 56 | { |
56 | if (-1 == asprintf (&cmd, | 57 | if (-1 == asprintf (&cmd, |
57 | "%s %s\n", | 58 | "%s %s\n", |
58 | "gnunet-gns -r -u", name)) | 59 | "gnunet-gns -r -u", |
60 | name)) | ||
59 | return -1; | 61 | return -1; |
60 | } | 62 | } |
61 | if (NULL == (p = popen (cmd, "r"))) | 63 | if (NULL == (p = popen (cmd, "r"))) |
@@ -63,7 +65,9 @@ gns_resolve_name (int af, | |||
63 | free (cmd); | 65 | free (cmd); |
64 | return -1; | 66 | return -1; |
65 | } | 67 | } |
66 | while (NULL != fgets (line, sizeof(line), p)) | 68 | while (NULL != fgets (line, |
69 | sizeof(line), | ||
70 | p)) | ||
67 | { | 71 | { |
68 | if (u->count >= MAX_ENTRIES) | 72 | if (u->count >= MAX_ENTRIES) |
69 | break; | 73 | break; |
@@ -72,7 +76,9 @@ gns_resolve_name (int af, | |||
72 | line[strlen(line)-1] = '\0'; | 76 | line[strlen(line)-1] = '\0'; |
73 | if (AF_INET == af) | 77 | if (AF_INET == af) |
74 | { | 78 | { |
75 | if (inet_pton(af, line, &(u->data.ipv4[u->count]))) | 79 | if (inet_pton(af, |
80 | line, | ||
81 | &u->data.ipv4[u->count])) | ||
76 | { | 82 | { |
77 | u->count++; | 83 | u->count++; |
78 | u->data_len += sizeof(ipv4_address_t); | 84 | u->data_len += sizeof(ipv4_address_t); |
@@ -86,7 +92,9 @@ gns_resolve_name (int af, | |||
86 | } | 92 | } |
87 | else if (AF_INET6 == af) | 93 | else if (AF_INET6 == af) |
88 | { | 94 | { |
89 | if (inet_pton(af, line, &(u->data.ipv6[u->count]))) | 95 | if (inet_pton(af, |
96 | line, | ||
97 | &u->data.ipv6[u->count])) | ||
90 | { | 98 | { |
91 | u->count++; | 99 | u->count++; |
92 | u->data_len += sizeof(ipv6_address_t); | 100 | u->data_len += sizeof(ipv6_address_t); |
@@ -105,7 +113,10 @@ gns_resolve_name (int af, | |||
105 | if (4 == ret) | 113 | if (4 == ret) |
106 | return -2; /* not for GNS */ | 114 | return -2; /* not for GNS */ |
107 | if (3 == ret) | 115 | if (3 == ret) |
108 | return -3; /* timeout */ | 116 | return -3; /* timeout -> not found */ |
117 | if ( (2 == ret) || (1 == ret) ) | ||
118 | return -2; /* launch failure -> service unavailable */ | ||
109 | return 0; | 119 | return 0; |
110 | } | 120 | } |
121 | |||
111 | /* end of nss_gns_query.c */ | 122 | /* end of nss_gns_query.c */ |