mirror of
https://github.com/rsyslog/rsyslog.git
synced 2025-12-20 09:40:42 +01:00
bugfix: check return value of malloc()
Error: NULL_RETURNS (CWE-476): rsyslog-7.4.10/plugins/omsnmp/omsnmp.c:264: returned_null: Function "malloc(size_t)" returns null (checked 140 out of 168 times). rsyslog-7.4.10/action.c:1197: example_checked: Example 1: "malloc(batchNumMsgs(pBatch) * 1UL)" has its value checked in "(active = malloc(batchNumMsgs(pBatch) * 1UL)) == NULL". rsyslog-7.4.10/grammar/lexer.l:302: example_checked: Example 2: "malloc(40UL)" has its value checked in "(bs = malloc(40UL)) == NULL". rsyslog-7.4.10/grammar/rainerscript.c:2483: example_checked: Example 3: "malloc(8UL)" has its value checked in "(ar->arr = malloc(8UL)) == NULL". rsyslog-7.4.10/plugins/imklog/bsd.c:221: example_checked: Example 4: "malloc(1UL * (iMaxLine + 1))" has its value checked in "(pRcv = (uchar *)malloc(1UL * (iMaxLine + 1))) == NULL". rsyslog-7.4.10/plugins/imuxsock/imuxsock.c:968: example_checked: Example 5: "malloc(1UL * (iMaxLine + 1))" has its value checked in "(pRcv = (uchar *)malloc(1UL * (iMaxLine + 1))) == NULL". rsyslog-7.4.10/plugins/omsnmp/omsnmp.c:264: var_assigned: Assigning: "pdu->enterprise" = null return value from "malloc(size_t)". rsyslog-7.4.10/plugins/omsnmp/omsnmp.c:265: dereference: Dereferencing a pointer that might be null "pdu->enterprise" when calling "memcpy(void * restrict, void const * restrict, size_t)".
This commit is contained in:
parent
fb172d5ec0
commit
fee75d299b
@ -263,7 +263,7 @@ static rsRetVal omsnmp_sendsnmp(instanceData *pData, uchar *psz)
|
||||
"failed '%s' with error '%s' \n", pData->szSyslogMessageOID, strErr);
|
||||
ABORT_FINALIZE(RS_RET_DISABLE_ACTION);
|
||||
}
|
||||
pdu->enterprise = (oid *) MALLOC(enterpriseoidlen * sizeof(oid));
|
||||
CHKmalloc(pdu->enterprise = (oid *) MALLOC(enterpriseoidlen * sizeof(oid)));
|
||||
memcpy(pdu->enterprise, enterpriseoid, enterpriseoidlen * sizeof(oid));
|
||||
pdu->enterprise_length = enterpriseoidlen;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user