diff options
Diffstat (limited to 'networking/inetd.c')
-rw-r--r-- | networking/inetd.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/networking/inetd.c b/networking/inetd.c index 873fd9528..05ad8c792 100644 --- a/networking/inetd.c +++ b/networking/inetd.c | |||
@@ -1278,6 +1278,7 @@ int inetd_main(int argc UNUSED_PARAM, char **argv) | |||
1278 | sep->se_count = 0; | 1278 | sep->se_count = 0; |
1279 | rearm_alarm(); /* will revive it in RETRYTIME sec */ | 1279 | rearm_alarm(); /* will revive it in RETRYTIME sec */ |
1280 | restore_sigmask(&omask); | 1280 | restore_sigmask(&omask); |
1281 | maybe_close(new_udp_fd); | ||
1281 | maybe_close(accepted_fd); | 1282 | maybe_close(accepted_fd); |
1282 | continue; /* -> check next fd in fd set */ | 1283 | continue; /* -> check next fd in fd set */ |
1283 | } | 1284 | } |
@@ -1298,17 +1299,18 @@ int inetd_main(int argc UNUSED_PARAM, char **argv) | |||
1298 | bb_perror_msg("vfork"+1); | 1299 | bb_perror_msg("vfork"+1); |
1299 | sleep(1); | 1300 | sleep(1); |
1300 | restore_sigmask(&omask); | 1301 | restore_sigmask(&omask); |
1302 | maybe_close(new_udp_fd); | ||
1301 | maybe_close(accepted_fd); | 1303 | maybe_close(accepted_fd); |
1302 | continue; /* -> check next fd in fd set */ | 1304 | continue; /* -> check next fd in fd set */ |
1303 | } | 1305 | } |
1304 | if (pid == 0) | 1306 | if (pid == 0) |
1305 | pid--; /* -1: "we did fork and we are child" */ | 1307 | pid--; /* -1: "we did fork and we are child" */ |
1306 | } | 1308 | } |
1307 | /* if pid == 0 here, we never forked */ | 1309 | /* if pid == 0 here, we didn't fork */ |
1308 | 1310 | ||
1309 | if (pid > 0) { /* parent */ | 1311 | if (pid > 0) { /* parent */ |
1310 | if (sep->se_wait) { | 1312 | if (sep->se_wait) { |
1311 | /* tcp wait: we passed listening socket to child, | 1313 | /* wait: we passed socket to child, |
1312 | * will wait for child to terminate */ | 1314 | * will wait for child to terminate */ |
1313 | sep->se_wait = pid; | 1315 | sep->se_wait = pid; |
1314 | remove_fd_from_set(sep->se_fd); | 1316 | remove_fd_from_set(sep->se_fd); |
@@ -1345,9 +1347,13 @@ int inetd_main(int argc UNUSED_PARAM, char **argv) | |||
1345 | setsid(); | 1347 | setsid(); |
1346 | /* "nowait" udp */ | 1348 | /* "nowait" udp */ |
1347 | if (new_udp_fd >= 0) { | 1349 | if (new_udp_fd >= 0) { |
1348 | len_and_sockaddr *lsa = xzalloc_lsa(sep->se_family); | 1350 | len_and_sockaddr *lsa; |
1351 | int r; | ||
1352 | |||
1353 | close(new_udp_fd); | ||
1354 | lsa = xzalloc_lsa(sep->se_family); | ||
1349 | /* peek at the packet and remember peer addr */ | 1355 | /* peek at the packet and remember peer addr */ |
1350 | int r = recvfrom(ctrl, NULL, 0, MSG_PEEK|MSG_DONTWAIT, | 1356 | r = recvfrom(ctrl, NULL, 0, MSG_PEEK|MSG_DONTWAIT, |
1351 | &lsa->u.sa, &lsa->len); | 1357 | &lsa->u.sa, &lsa->len); |
1352 | if (r < 0) | 1358 | if (r < 0) |
1353 | goto do_exit1; | 1359 | goto do_exit1; |