From 22dcb8d02e44a137d4354c0c2503698927bae898 Mon Sep 17 00:00:00 2001 From: Jeff Layton Date: Wed, 30 Apr 2014 12:00:05 -0400 Subject: gssd: handle malloc failure appropriately in do_downcall ...and get rid of some pointless NULL ptr checks. Signed-off-by: Jeff Layton Signed-off-by: Steve Dickson --- utils/gssd/gssd_proc.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/utils/gssd/gssd_proc.c b/utils/gssd/gssd_proc.c index 33cfeb2..5f7fb32 100644 --- a/utils/gssd/gssd_proc.c +++ b/utils/gssd/gssd_proc.c @@ -694,6 +694,9 @@ do_downcall(int k5_fd, uid_t uid, struct authgss_private_data *pd, sizeof(pd->pd_ctx_hndl.length) + pd->pd_ctx_hndl.length + sizeof(context_token->length) + context_token->length; p = buf = malloc(buf_size); + if (!buf) + goto out_err; + end = buf + buf_size; /* context_timeout set by -t option overrides context lifetime */ @@ -706,10 +709,10 @@ do_downcall(int k5_fd, uid_t uid, struct authgss_private_data *pd, if (write_buffer(&p, end, context_token)) goto out_err; if (write(k5_fd, buf, p - buf) < p - buf) goto out_err; - if (buf) free(buf); + free(buf); return 0; out_err: - if (buf) free(buf); + free(buf); printerr(1, "Failed to write downcall!\n"); return -1; } -- cgit