mirror of
https://github.com/rsyslog/rsyslog.git
synced 2025-12-19 17:20:42 +01:00
imgssapi: fix potential memory leak detected by clang static analyzer
... and some cosmetic fixes to remove static analyzer false positives
This commit is contained in:
parent
69b95178aa
commit
9dc9a90e3d
@ -326,6 +326,12 @@ addGSSListener(void __attribute__((unused)) *pVal, uchar *pNewVal)
|
||||
RETiRet;
|
||||
}
|
||||
|
||||
/* I suppress the following function from clang static analyzer,
|
||||
* as it most probably has a false positive. Maybe someone with
|
||||
* better understanding might try to fix this warning:
|
||||
* imgssapi.c:363:5: warning: Potential leak of memory pointed to by 'pGSrv'
|
||||
*/
|
||||
#ifndef __clang_analyzer__
|
||||
static rsRetVal
|
||||
actGSSListener(uchar *port)
|
||||
{
|
||||
@ -367,6 +373,7 @@ finalize_it:
|
||||
}
|
||||
RETiRet;
|
||||
}
|
||||
#endif // #ifndef __clang_analyzer__
|
||||
|
||||
|
||||
/* returns 0 if all went OK, -1 if it failed */
|
||||
@ -419,6 +426,7 @@ OnSessAcceptGSS(tcpsrv_t *pThis, tcps_sess_t *pSess)
|
||||
gss_sess_t *pGSess;
|
||||
uchar *pszPeer = NULL;
|
||||
int lenPeer = 0;
|
||||
char *buf = NULL;
|
||||
|
||||
assert(pSess != NULL);
|
||||
|
||||
@ -426,13 +434,6 @@ OnSessAcceptGSS(tcpsrv_t *pThis, tcps_sess_t *pSess)
|
||||
pGSess = (gss_sess_t*) pSess->pUsr;
|
||||
allowedMethods = pGSrv->allowedMethods;
|
||||
if(allowedMethods & ALLOWEDMETHOD_GSS) {
|
||||
/* Buffer to store raw message in case that
|
||||
* gss authentication fails halfway through. This buffer
|
||||
* is currently dynamically allocated, for performance
|
||||
* reasons we should look for a better way to do it.
|
||||
* rgerhars, 2008-09-02
|
||||
*/
|
||||
char *buf;
|
||||
int ret = 0;
|
||||
CHKmalloc(buf = (char*) MALLOC(glbl.GetMaxLine() + 1));
|
||||
|
||||
@ -578,6 +579,7 @@ OnSessAcceptGSS(tcpsrv_t *pThis, tcps_sess_t *pSess)
|
||||
}
|
||||
|
||||
finalize_it:
|
||||
free(buf);
|
||||
RETiRet;
|
||||
}
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/* gss-misc.c
|
||||
* This is a miscellaneous helper class for gss-api features.
|
||||
*
|
||||
* Copyright 2007 Rainer Gerhards and Adiscon GmbH.
|
||||
* Copyright 2007-2017 Rainer Gerhards and Adiscon GmbH.
|
||||
*
|
||||
* This file is part of rsyslog.
|
||||
*
|
||||
@ -171,7 +171,7 @@ static int write_all(int fd, char *buf, unsigned int nbyte)
|
||||
static int recv_token(int s, gss_buffer_t tok)
|
||||
{
|
||||
int ret;
|
||||
unsigned char lenbuf[4];
|
||||
unsigned char lenbuf[4] = "xxx"; // initialized to make clang static analyzer happy
|
||||
unsigned int len;
|
||||
|
||||
ret = read_all(s, (char *) lenbuf, 4);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user