mirror of
https://github.com/rsyslog/rsyslog.git
synced 2025-12-18 08:40:42 +01:00
mmsnmptrapd: fix potential misadressing
Detected by clang static analyzer.
This commit is contained in:
parent
bc2cc8feb2
commit
546b6010db
@ -187,23 +187,22 @@ getSubstring(uchar **psrc, uchar delim, uchar *dst, int lenDst)
|
||||
* dst, lenDst (receive buffer) must be given. lenDst is
|
||||
* max length on entry and actual length on exit.
|
||||
*/
|
||||
static int
|
||||
getTagComponent(uchar *tag, uchar *dst, int *lenDst)
|
||||
static int ATTR_NONNULL()
|
||||
getTagComponent(uchar *tag, uchar *const dst, int *const lenDst)
|
||||
{
|
||||
int end = *lenDst - 1; /* -1 for NUL-char! */
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
if(tag[i] != '/')
|
||||
goto done;
|
||||
++tag;
|
||||
while(i < end && tag[i] != '\0' && tag[i] != ' ' && tag[i] != '/') {
|
||||
dst[i] = tag[i];
|
||||
++i;
|
||||
if(tag[i] == '/') {
|
||||
++tag;
|
||||
while(i < end && tag[i] != '\0' && tag[i] != ' ' && tag[i] != '/') {
|
||||
dst[i] = tag[i];
|
||||
++i;
|
||||
}
|
||||
}
|
||||
dst[i] = '\0';
|
||||
*lenDst = i;
|
||||
done:
|
||||
return i;
|
||||
}
|
||||
|
||||
@ -253,7 +252,7 @@ CODESTARTdoAction
|
||||
getTagComponent(pszTag+pData->lenTagID+lenSever, pszHost, &lenHost);
|
||||
DBGPRINTF("mmsnmptrapd: sever '%s'(%d), host '%s'(%d)\n", pszSever, lenSever, pszHost,lenHost);
|
||||
|
||||
if(pszHost[lenHost-1] == ':') {
|
||||
if(lenHost > 0 && pszHost[lenHost-1] == ':') {
|
||||
pszHost[lenHost-1] = '\0';
|
||||
--lenHost;
|
||||
}
|
||||
@ -270,8 +269,8 @@ ENDdoAction
|
||||
/* Build the severity mapping table based on user-provided configuration
|
||||
* settings.
|
||||
*/
|
||||
static rsRetVal
|
||||
buildSeverityMapping(instanceData *pData)
|
||||
static rsRetVal ATTR_NONNULL()
|
||||
buildSeverityMapping(instanceData *const pData)
|
||||
{
|
||||
uchar pszSev[512];
|
||||
uchar pszSevCode[512];
|
||||
@ -305,14 +304,14 @@ buildSeverityMapping(instanceData *pData)
|
||||
/* we enqueue at the top, so the two lines below do all we need! */
|
||||
node->next = pData->severMap;
|
||||
pData->severMap = node;
|
||||
node = NULL;
|
||||
DBGPRINTF("mmsnmptrapd: severity string '%s' mapped to code %d\n",
|
||||
pszSev, sevCode);
|
||||
}
|
||||
|
||||
finalize_it:
|
||||
if(iRet != RS_RET_OK) {
|
||||
if(node != NULL)
|
||||
free(node);
|
||||
free(node);
|
||||
}
|
||||
RETiRet;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user