]> git.ipfire.org Git - thirdparty/knot-dns.git/commitdiff
libknot/probe: fix send() data length for resend in knot_probe_produce()
authorDaniel Salzman <daniel.salzman@nic.cz>
Mon, 31 May 2021 12:52:07 +0000 (14:52 +0200)
committerDaniel Salzman <daniel.salzman@nic.cz>
Mon, 31 May 2021 13:04:23 +0000 (15:04 +0200)
src/libknot/probe/probe.c

index 478a7d1fc245de376efb92aea9bd0497ba7221cd..36c7b815c6f30e85560e2f30dbc703acad956545 100644 (file)
@@ -158,14 +158,14 @@ int knot_probe_produce(knot_probe_t *probe, const knot_probe_data_t *data, uint8
                return KNOT_EINVAL;
        }
 
-       uint8_t diff = KNOT_DNAME_MAXLEN - data->query.qname_len;
-       if (send(probe->fd, data, sizeof(*data) - diff, 0) == -1) {
+       size_t used_len = sizeof(*data) - KNOT_DNAME_MAXLEN + data->query.qname_len;
+       if (send(probe->fd, data, used_len, 0) == -1) {
                struct timespec now = time_now();
                if (now.tv_sec - probe->last_unconn_time > 2) {
                        probe->last_unconn_time = now.tv_sec;
                        if ((errno == ENOTCONN || errno == ECONNREFUSED) &&
                            probe_connect(probe) == 0 &&
-                           send(probe->fd, data, sizeof(*data), 0) > 0) {
+                           send(probe->fd, data, used_len, 0) > 0) {
                                return KNOT_EOK;
                        }
                }