Free 'ptr' in case realloc was successful, but the next check fails.
Fix for clang scan-build report:
5886 if (!success) {
35 Potential leak of memory pointed to by 'ptr'
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Added assert to while loop to make sure not to read over the array boundry.
Fix for Coverity issue from Ceph project:
CID 1160832 (#1 of 1): Out-of-bounds read (OVERRUN_STATIC)
37. overrun-local: Overrunning static array "buf", with 8192
elements, at position 8192 with index variable "len".
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
fix for cgcc warnings:
src/civetweb.c:5455:56: warning: Using plain integer as NULL pointer
src/civetweb.c:5696:28: warning: Using plain integer as NULL pointer
src/civetweb.c:5698:26: warning: Using plain integer as NULL pointer
src/civetweb.c:6456:34: warning: Using plain integer as NULL pointer
src/civetweb.c:6643:34: warning: Using plain integer as NULL pointer
src/civetweb.c:6811:29: warning: Using plain integer as NULL pointer
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
fix for cgcc warning:
src/main.c:238:48: warning: Using plain integer as NULL pointer
src/main.c:246:44: warning: Using plain integer as NULL pointer
src/main.c:418:17: warning: Using plain integer as NULL pointer
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Fix for cgcc warning:
src/civetweb.c:6189:22: warning: symbol 'mg_connect' was not declared.
Should it be static?
src/civetweb.c:6743:6: warning: symbol 'get_system_name' was not declared.
Should it be static?
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
[src/civetweb.c:3250]: (style) Array index 'i' is used before limits check.
[src/civetweb.c:3254]: (style) Array index 'i' is used before limits check.
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
[src/civetweb.c:5728]: (warning) %d in format string (no. 2) requires
'int *' but the argument type is 'unsigned int *'.
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
[src/civetweb.c:366]: (warning) %d in format string (no. 4) requires
'int' but the argument type is 'unsigned int'.
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Change %u to %lu and cast size_t to unsigned long to fix:
[src/civetweb.c:360]: (warning) %u in format string (no. 2) requires
'unsigned int' but the argument type is 'size_t {aka unsigned long}'.
[src/civetweb.c:360]: (warning) %u in format string (no. 3) requires
'unsigned int' but the argument type is 'unsigned long'.
[src/civetweb.c:360]: (warning) %u in format string (no. 4) requires
'unsigned int' but the argument type is 'unsigned long'.
[src/civetweb.c:388]: (warning) %u in format string (no. 2) requires
'unsigned int' but the argument type is 'size_t {aka unsigned long}'.
[src/civetweb.c:388]: (warning) %u in format string (no. 3) requires
'unsigned int' but the argument type is 'unsigned long'.
[src/civetweb.c:388]: (warning) %u in format string (no. 4) requires
'unsigned int' but the argument type is 'unsigned long'.
[src/civetweb.c:414]: (warning) %u in format string (no. 2) requires
'unsigned int' but the argument type is 'size_t {aka unsigned long}'.
[src/civetweb.c:414]: (warning) %u in format string (no. 3) requires
'unsigned int' but the argument type is 'unsigned long'.
[src/civetweb.c:414]: (warning) %u in format string (no. 4) requires
'unsigned int' but the argument type is 'unsigned long'.
[src/civetweb.c:421]: (warning) %u in format string (no. 2) requires
'unsigned int' but the argument type is 'size_t {aka unsigned long}'.
[src/civetweb.c:421]: (warning) %u in format string (no. 3) requires
'unsigned int' but the argument type is 'unsigned long'.
[src/civetweb.c:421]: (warning) %u in format string (no. 4) requires
'unsigned int' but the argument type is 'unsigned long'.
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Fix for:
[test/unit_test.c:827]: (warning) printf format string requires 0
parameters but 1 is given.
[test/unit_test.c:833]: (warning) printf format string requires 0
parameters but 1 is given.
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Fix handling of realloc. If realloc() fails it returns NULL, assigning
the return value of realloc() directly to the pointer without checking
for the result will lead to a memory leak in error case.
Use a temporary pointer to hold the result of realloc().
Fix for:
[src/civetweb.c:409]: (error) Common realloc mistake: 'data' nulled but
not freed upon failure
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Fix warning: passing 'char **' to parameter of type 'const char **' discards
qualifiers in nested pointer types [-Wincompatible-pointer-types]
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>