ssize_t l;
struct cmsghdr *cmsg;
gboolean found_ttl = FALSE, found_iface = FALSE;
+ guint ms;
g_assert(fd >= 0);
g_assert(ret_sa);
g_assert(ret_iface);
g_assert(ret_ttl);
- p = avahi_dns_packet_new(0);
+ if (ioctl(fd, FIONREAD, &ms) < 0) {
+ g_warning("ioctl(): %s", strerror(errno));
+ goto fail;
+ }
+
+ p = avahi_dns_packet_new(ms + AVAHI_DNS_PACKET_EXTRA_SIZE);
io.iov_base = AVAHI_DNS_PACKET_DATA(p);
io.iov_len = p->max_size;
msg.msg_flags = 0;
if ((l = recvmsg(fd, &msg, 0)) < 0) {
- g_warning("recvmsg(): %s\n", strerror(errno));
+ g_warning("recvmsg(): %s", strerror(errno));
goto fail;
}
struct iovec io;
uint8_t aux[64];
ssize_t l;
+ guint ms;
+
struct cmsghdr *cmsg;
gboolean found_ttl = FALSE, found_iface = FALSE;
g_assert(ret_iface);
g_assert(ret_ttl);
- p = avahi_dns_packet_new(0);
+ if (ioctl(fd, FIONREAD, &ms) < 0) {
+ g_warning("ioctl(): %s", strerror(errno));
+ goto fail;
+ }
+
+ p = avahi_dns_packet_new(ms + AVAHI_DNS_PACKET_EXTRA_SIZE);
io.iov_base = AVAHI_DNS_PACKET_DATA(p);
io.iov_len = p->max_size;
msg.msg_controllen = sizeof(aux);
msg.msg_flags = 0;
- if ((l = recvmsg(fd, &msg, 0)) < 0)
+ if ((l = recvmsg(fd, &msg, 0)) < 0) {
+ g_warning("recvmsg(): %s", strerror(errno));
goto fail;
+ }
p->size = (size_t) l;