Changeset 5376
- Timestamp:
- Jul 5, 2016 12:53:20 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjlib/src/pj/addr_resolv_sock.c
r5319 r5376 155 155 addr_size = addr->sa_len; 156 156 } 157 PJ_ASSERT_ON_FAIL(addr_size <= sizeof(pj_sockaddr), 157 PJ_ASSERT_ON_FAIL(addr_size <= sizeof(pj_sockaddr), continue); 158 158 pj_memcpy(&ai[i].ai_addr, addr, addr_size); 159 159 PJ_SOCKADDR_RESET_LEN(&ai[i].ai_addr); … … 164 164 165 165 *count = i; 166 if (*count == 0) 167 status = PJ_ERESOLVE; 168 166 169 } else { 167 170 status = PJ_ERESOLVE; … … 184 187 185 188 /* Enumerate each item in the result */ 189 rc = 0; 186 190 for (i=0; i<*count && res; res=res->ai_next) { 187 191 /* Ignore unwanted address families */ … … 191 195 /* Store canonical name (possibly truncating the name) */ 192 196 if (res->ai_canonname) { 193 pj_ansi_strncpy(ai[ i].ai_canonname, res->ai_canonname,194 sizeof(ai[ i].ai_canonname));195 ai[ i].ai_canonname[sizeof(ai[i].ai_canonname)-1] = '\0';197 pj_ansi_strncpy(ai[rc].ai_canonname, res->ai_canonname, 198 sizeof(ai[rc].ai_canonname)); 199 ai[rc].ai_canonname[sizeof(ai[rc].ai_canonname)-1] = '\0'; 196 200 } else { 197 pj_ansi_strcpy(ai[ i].ai_canonname, nodecopy);201 pj_ansi_strcpy(ai[rc].ai_canonname, nodecopy); 198 202 } 199 203 200 204 /* Store address */ 201 205 PJ_ASSERT_ON_FAIL(res->ai_addrlen <= sizeof(pj_sockaddr), continue); 202 pj_memcpy(&ai[ i].ai_addr, res->ai_addr, res->ai_addrlen);203 PJ_SOCKADDR_RESET_LEN(&ai[ i].ai_addr);206 pj_memcpy(&ai[rc].ai_addr, res->ai_addr, res->ai_addrlen); 207 PJ_SOCKADDR_RESET_LEN(&ai[rc].ai_addr); 204 208 205 209 /* Next slot */ 206 ++ i;207 } 208 209 *count = i;210 ++rc; 211 } 212 213 *count = rc; 210 214 211 215 freeaddrinfo(orig_res); 212 216 213 217 /* Done */ 214 return PJ_SUCCESS;218 return (*count > 0? PJ_SUCCESS : PJ_ERESOLVE); 215 219 #endif 216 220 … … 286 290 } 287 291 288 return PJ_SUCCESS;292 return (*count > 0? PJ_SUCCESS : PJ_ERESOLVE); 289 293 290 294 } else {
Note: See TracChangeset
for help on using the changeset viewer.