Skip to content

Commit 992a558

Browse files
committed
http: clear a UAF misdiagnosis in cov-scan
18. freed_arg: free frees prequestx->stub_and_verifier.data. CID 1469069 (#1 of 1): Use after free (USE_AFTER_FREE) 19. use_after_free: Using freed pointer prequestx->stub_and_verifier.data (False positive; data and vdata are the same thing, because of the union.)
1 parent f8244d1 commit 992a558

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

exch/http/pdu_processor.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2994,7 +2994,6 @@ int pdu_processor_rts_input(const char *pbuff, uint16_t length,
29942994
int pdu_processor_input(PDU_PROCESSOR *pprocessor, const char *pbuff,
29952995
uint16_t length, DCERPC_CALL **ppcall)
29962996
{
2997-
void *pdata;
29982997
NDR_PULL ndr;
29992998
BOOL b_result;
30002999
uint32_t flags;
@@ -3085,7 +3084,7 @@ int pdu_processor_input(PDU_PROCESSOR *pprocessor, const char *pbuff,
30853084
return PDU_PROCESSOR_OUTPUT;
30863085
}
30873086
alloc_size = strange_roundup(alloc_size - 1, 16 * 1024);
3088-
pdata = malloc(alloc_size);
3087+
auto pdata = static_cast<uint8_t *>(malloc(alloc_size));
30893088
if (NULL == pdata) {
30903089
if (FALSE == pdu_processor_fault(pcall,
30913090
DCERPC_FAULT_OTHER)) {
@@ -3099,7 +3098,7 @@ int pdu_processor_input(PDU_PROCESSOR *pprocessor, const char *pbuff,
30993098
memcpy(pdata, prequest->stub_and_verifier.data,
31003099
prequest->stub_and_verifier.length);
31013100
free(prequest->stub_and_verifier.data);
3102-
prequest->stub_and_verifier.vdata = pdata;
3101+
prequest->stub_and_verifier.data = pdata;
31033102
pcall->alloc_size = alloc_size;
31043103
}
31053104
} else {
@@ -3145,7 +3144,7 @@ int pdu_processor_input(PDU_PROCESSOR *pprocessor, const char *pbuff,
31453144
return PDU_PROCESSOR_OUTPUT;
31463145
}
31473146
alloc_size = strange_roundup(alloc_size - 1, 16 * 1024);
3148-
pdata = malloc(alloc_size);
3147+
auto pdata = static_cast<uint8_t *>(malloc(alloc_size));
31493148
if (NULL == pdata) {
31503149
pdu_processor_free_call(pcallx);
31513150
if (FALSE == pdu_processor_fault(pcall,
@@ -3159,7 +3158,7 @@ int pdu_processor_input(PDU_PROCESSOR *pprocessor, const char *pbuff,
31593158
memcpy(pdata, prequestx->stub_and_verifier.data,
31603159
prequestx->stub_and_verifier.length);
31613160
free(prequestx->stub_and_verifier.data);
3162-
prequestx->stub_and_verifier.vdata = pdata;
3161+
prequestx->stub_and_verifier.data = pdata;
31633162
pcallx->alloc_size = alloc_size;
31643163
}
31653164

0 commit comments

Comments
 (0)