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