if (hdr->len > RTRPDU_ERROR_REPORT_MAX_LEN) {
return pr_op_err(
- "RTR client %s sent a large Error Report PDU (%u bytes). This looks broken, so I'm dropping the connection.",
+ "%s: Error Report PDU is too big (%u bytes).",
+ stream->addr, hdr->len
+ );
+ }
+ if (hdr->len < RTR_HDR_LEN + 8) { /* hdr + errpdu len + errmsg len */
+ return pr_op_err(
+ "%s: Error Report PDU is too small (%u bytes).",
stream->addr, hdr->len
);
}
* have sent this PDU. Looks like someone is messing with us.
*/
error = pr_op_err(
- "RTR client %s sent an Error Report PDU containing a large error PDU (%u bytes). This looks broken/insecure; I'm dropping the connection.",
+ "%s: Error Report PDU's embedded PDU is too big (%u bytes).",
stream->addr, errpdu_len
);
goto revert_errpdu_len;
}
+ if (hdr->len < RTR_HDR_LEN + 8 + errpdu_len) {
+ error = pr_op_err(
+ "%s: Invalid Length of Encapsulated PDU (%u); PDU length is %u.",
+ stream->addr, errpdu_len, hdr->len
+ );
+ goto revert_errpdu_len;
+ }
/* Error PDU */
if (get_length(stream) < errpdu_len) {
stream->start += 4;
if (hdr->len != rtrpdu_error_report_len(errpdu_len, errmsg_len)) {
error = pr_op_err(
- "RTR client %s sent a malformed Error Report PDU; header length is %u, but effective length is %u + %u + %u + %u + %u.",
+ "%s: Error Report PDU is malformed; header length is %u, but effective length is %u + %u + %u + %u + %u.",
stream->addr, hdr->len,
RTR_HDR_LEN, 4, errpdu_len, 4, errmsg_len
);
pr_op_err("%s '%s' down: POLLERR (Generic error)", what, addr);
if (pfd->revents & POLLNVAL)
pr_op_err("%s '%s' down: POLLNVAL (fd not open)", what, addr);
+ if (!(pfd->revents & (POLLHUP | POLLERR | POLLNVAL)))
+ pr_op_info("%s '%s' down.", what, addr);
}
static void
/* PR_DEBUG_MSG("pfd:%d server:%d", pfd->fd, server->fd); */
if ((pfd->fd == -1) && (server->fd != -1)) {
+ print_poll_failure(pfd, "Server", server->addr);
close(server->fd);
server->fd = -1;
- print_poll_failure(pfd, "Server", server->addr);
}
}
/* PR_DEBUG_MSG("pfd:%d client:%d", pfd->fd, client->fd); */
if ((pfd->fd == -1) && (pdustream_fd(client) != -1)) {
+ print_poll_failure(pfd, "Client", pdustream_addr(client));
pdustream_destroy(&client);
clients.array[i] = NULL;
- print_poll_failure(pfd, "Client", pdustream_addr(client));
}
}