diff options
| author | Dirk Engling <erdgeist@erdgeist.org> | 2026-10-24 21:51:54 +0200 |
|---|---|---|
| committer | Dirk Engling <erdgeist@erdgeist.org> | 2026-10-24 21:51:54 +0200 |
| commit | 50c7599ee584131e8ecb5d0742b46c7a7aeee0a9 (patch) | |
| tree | 520ce37b9f490f94eec1c798254dc1b95be1626f | |
| parent | 96fa1b7327b35cdeca6c77f2fdde906cabc437d8 (diff) | |
Properly handle socket_recv errors
| -rw-r--r-- | ot_udp.c | 5 |
1 files changed, 3 insertions, 2 deletions
| @@ -81,9 +81,10 @@ int handle_udp6(int64_t serversocket, struct ot_workstruct *ws) { | |||
| 81 | uint16_t port, remoteport; | 81 | uint16_t port, remoteport; |
| 82 | size_t byte_count, scrape_count; | 82 | size_t byte_count, scrape_count; |
| 83 | 83 | ||
| 84 | byte_count = socket_recv6(serversocket, ws->inbuf, G_INBUF_SIZE, remoteip, &remoteport, &scopeid); | 84 | ssize_t result = socket_recv6(serversocket, ws->inbuf, G_INBUF_SIZE, remoteip, &remoteport, &scopeid); |
| 85 | if (!byte_count) | 85 | if (result <= 0) |
| 86 | return 0; | 86 | return 0; |
| 87 | byte_count = (size_t)result; | ||
| 87 | 88 | ||
| 88 | stats_issue_event(EVENT_ACCEPT, FLAG_UDP, (uintptr_t)remoteip); | 89 | stats_issue_event(EVENT_ACCEPT, FLAG_UDP, (uintptr_t)remoteip); |
| 89 | stats_issue_event(EVENT_READ, FLAG_UDP, byte_count); | 90 | stats_issue_event(EVENT_READ, FLAG_UDP, byte_count); |
