if (pkt_hdr->data_length)
{
data = g_malloc0(pkt_hdr->data_length);
if (read_all(fd, data, pkt_hdr->data_length) < 0)
if (read_all(fd, data, pkt_hdr->data_length) != pkt_hdr->data_length)
g_free(data);
data = NULL;