Skip to content

Commit 5810907

Browse files
committed
Check fd usage before content logging, issue #88
reported by @victorjulien This change is expected to prevent sslproxy to crash if it runs out of fds while content logging.
1 parent 41d7f64 commit 5810907

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/pxyconn.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,12 @@ pxy_prepare_logging_local_procinfo(pxy_conn_ctx_t *ctx)
615615
}
616616
#endif /* HAVE_LOCAL_PROCINFO */
617617

618+
static int check_fd_usage(
619+
#ifdef DEBUG_PROXY
620+
pxy_conn_ctx_t *ctx
621+
#endif /* DEBUG_PROXY */
622+
);
623+
618624
static int
619625
pxy_prepare_logging(pxy_conn_ctx_t *ctx)
620626
{
@@ -627,6 +633,16 @@ pxy_prepare_logging(pxy_conn_ctx_t *ctx)
627633
}
628634
#endif /* HAVE_LOCAL_PROCINFO */
629635
if (WANT_CONTENT_LOG(ctx)) {
636+
if (check_fd_usage(
637+
#ifdef DEBUG_PROXY
638+
ctx
639+
#endif /* DEBUG_PROXY */
640+
) == -1) {
641+
ctx->enomem = 1;
642+
pxy_conn_term(ctx, 1);
643+
return -1;
644+
}
645+
630646
if (log_content_open(&ctx->logctx, ctx->global,
631647
(struct sockaddr *)&ctx->srcaddr,
632648
ctx->srcaddrlen,

0 commit comments

Comments
 (0)