Revert "Revert "oran-shell-release: release image for F""
[pti/rtp.git] / meta-starlingx / meta-stx-distro / recipes-security / gssproxy / files / Fix-error-handling-in-gpm_send_buffer-gpm_recv_buffe.patch
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
5
6 Signed-off-by: Alexander Scheel <alexander.m.scheel@gmail.com>
7 Reviewed-by: Robbie Harwood <rharwood@redhat.com>
8 Merges: #213
9 [rharwood@redhat.com: commit message formatting, copyright update]
10 (cherry picked from commit f2530fc280dd84e6abc0f5475e261aa0d2ee2a21)
11 ---
12  proxy/src/client/gpm_common.c | 18 ++++++------------
13  1 file changed, 6 insertions(+), 12 deletions(-)
14
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
19 @@ -1,4 +1,4 @@
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 */
22  
23  #include "gssapi_gpm.h"
24  #include <sys/types.h>
25 @@ -415,10 +415,7 @@ static int gpm_send_buffer(struct gpm_ctx *gpmctx,
26      ret = 0;
27  
28  done:
29 -    if (ret) {
30 -        /* on errors we can only close the fd and return */
31 -        gpm_close_socket(gpmctx);
32 -    }
33 +    /* we only need to return as gpm_retry_socket closes the socket */
34      return ret;
35  }
36  
37 @@ -488,9 +485,10 @@ static int gpm_recv_buffer(struct gpm_ctx *gpmctx,
38  
39  done:
40      if (ret) {
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); */
46 +        free(*buffer);
47 +        *buffer = NULL;
48      }
49      return ret;
50  }
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);
54  
55 -            /* Free buffer and set it to NULL to prevent free(xdr_reply_ctx) */
56 -            free(*recv_buffer);
57 -            *recv_buffer = NULL;
58 -
59              if (ret != 0)
60                  return ret;
61              ret = ETIMEDOUT;