Fix gcc 8 warnings.

This commit is contained in:
Jim Hague 2019-01-15 17:13:13 +00:00
parent 9024fd7736
commit 09ca9a826b
1 changed files with 19 additions and 10 deletions

View File

@ -68,6 +68,15 @@ typedef struct ta_iter {
char digest[2048];
} ta_iter;
static void strcpytrunc(char* dst, const char* src, size_t dstsize)
{
size_t to_copy = strlen(src);
if (to_copy >= dstsize)
to_copy = dstsize -1;
memcpy(dst, src, to_copy);
dst[to_copy] = '\0';
}
/**
* XML convert DateTime element to time_t.
* [-]CCYY-MM-DDThh:mm:ss[Z|(+|-)hh:mm]
@ -190,7 +199,7 @@ static ta_iter *ta_iter_next(ta_iter *ta)
else if (level == 0 && cur) {
/* <Zone> content ready */
(void) strncpy( ta->zone, value
strcpytrunc( ta->zone, value
, sizeof(ta->zone));
/* Reset to start of <TrustAnchor> */
@ -366,19 +375,19 @@ static ta_iter *ta_iter_next(ta_iter *ta)
DEBUG_ANCHOR("elem end: %s\n", value);
switch (elem_type) {
case KEYTAG:
(void) strncpy( ta->keytag, value
strcpytrunc( ta->keytag, value
, sizeof(ta->keytag));
break;
case ALGORITHM:
(void) strncpy( ta->algorithm, value
strcpytrunc( ta->algorithm, value
, sizeof(ta->algorithm));
break;
case DIGESTTYPE:
(void) strncpy( ta->digesttype, value
strcpytrunc( ta->digesttype, value
, sizeof(ta->digesttype));
break;
case DIGEST:
(void) strncpy( ta->digest, value
strcpytrunc( ta->digest, value
, sizeof(ta->digest));
break;
}