1 From 027596a3df85d11948f4fb3a28d27d6523645589 Mon Sep 17 00:00:00 2001
2 From: Alexander Scheel <alexander.m.scheel@gmail.com>
3 Date: Thu, 14 Sep 2017 11:24:39 -0500
4 Subject: [PATCH] Fix error handling in gpm_send_buffer/gpm_recv_buffer
6 Signed-off-by: Alexander Scheel <alexander.m.scheel@gmail.com>
7 Reviewed-by: Robbie Harwood <rharwood@redhat.com>
9 [rharwood@redhat.com: commit message formatting, copyright update]
10 (cherry picked from commit f2530fc280dd84e6abc0f5475e261aa0d2ee2a21)
12 proxy/src/client/gpm_common.c | 18 ++++++------------
13 1 file changed, 6 insertions(+), 12 deletions(-)
15 diff --git a/proxy/src/client/gpm_common.c b/proxy/src/client/gpm_common.c
16 index b14e846..0d314fa 100644
17 --- a/proxy/src/client/gpm_common.c
18 +++ b/proxy/src/client/gpm_common.c
20 -/* Copyright (C) 2011 the GSS-PROXY contributors, see COPYING for license */
21 +/* Copyright (C) 2011,2017 the GSS-PROXY contributors, see COPYING for license */
23 #include "gssapi_gpm.h"
24 #include <sys/types.h>
25 @@ -415,10 +415,7 @@ static int gpm_send_buffer(struct gpm_ctx *gpmctx,
30 - /* on errors we can only close the fd and return */
31 - gpm_close_socket(gpmctx);
33 + /* we only need to return as gpm_retry_socket closes the socket */
37 @@ -488,9 +485,10 @@ static int gpm_recv_buffer(struct gpm_ctx *gpmctx,
41 - /* on errors we can only close the fd and return */
42 - gpm_close_socket(gpmctx);
43 - gpm_epoll_close(gpmctx);
44 + /* on errors, free the buffer to prevent calling
45 + * xdr_destroy(&xdr_reply_ctx); */
51 @@ -560,10 +558,6 @@ static int gpm_send_recv_loop(struct gpm_ctx *gpmctx, char *send_buffer,
52 /* Close and reopen socket before trying again */
53 ret = gpm_retry_socket(gpmctx);
55 - /* Free buffer and set it to NULL to prevent free(xdr_reply_ctx) */
57 - *recv_buffer = NULL;