fix coverity scan errors

This commit is contained in:
Enno Rehling 2017-12-12 09:19:35 +01:00
parent 77921a94ba
commit 02248e0c54
5 changed files with 14 additions and 5 deletions

View File

@ -13,6 +13,7 @@ endif (MSVC)
INCLUDE (CheckSymbolExists)
CHECK_SYMBOL_EXISTS(strlcat string.h HAVE_STRLCAT)
CHECK_SYMBOL_EXISTS(strdup string.h HAVE_STRDUP)
find_package (SQLite3)
find_package (BerkeleyDB)

View File

@ -267,9 +267,13 @@ add_test(server test_eressea)
install(TARGETS eressea DESTINATION "bin")
if (HAVE_STRLCAT)
add_definitions(-DHAVE_BSDSTRING)
add_definitions(-DHAVE_BSDSTRING)
endif(HAVE_STRLCAT)
if (HAVE_STRDUP)
add_definitions(-DHAVE_STRDUP)
endif(HAVE_STRDUP)
if (DB_FOUND)
include_directories (${DB_INCLUDE_DIR})
target_link_libraries(convert ${DB_LIBRARIES})

View File

@ -190,7 +190,7 @@ static char *sidename(side * s)
static char sidename_buf[4][SIDENAMEBUFLEN]; /* STATIC_RESULT: used for return, not across calls */
bufno = bufno % 4;
strncpy(sidename_buf[bufno], factionname(s->stealthfaction ? s->stealthfaction : s->faction), SIDENAMEBUFLEN);
strlcpy(sidename_buf[bufno], factionname(s->stealthfaction ? s->stealthfaction : s->faction), SIDENAMEBUFLEN);
return sidename_buf[bufno++];
}

View File

@ -6,6 +6,7 @@
#include <critbit.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
@ -14,12 +15,15 @@ void odata_create(order_data **pdata, size_t len, const char *str)
order_data *data;
char *result;
assert(pdata);
data = malloc(sizeof(order_data) + len + 1);
data->_refcount = 1;
result = (char *)(data + 1);
data->_str = (len > 0) ? result : NULL;
if (str) strcpy(result, str);
if (pdata) *pdata = data;
if (str) {
strcpy(result, str);
}
*pdata = data;
}
void odata_release(order_data * od)

View File

@ -277,7 +277,7 @@ static void dragon_name(unit * u)
else {
char n[32];
snprintf(n, sizeof(n), "%s%s%s", silbe1[rng_int() % SIL1], silbe2[rng_int() % SIL1], silbe3[rng_int() % SIL1]);
snprintf(n, sizeof(n), "%s%s%s", silbe1[rng_int() % SIL1], silbe2[rng_int() % SIL2], silbe3[rng_int() % SIL3]);
if (rng_int() % 5 > 2) {
sprintf(name, "%s, %s", n, str); /* "Name, der Titel" */
}