mirror of https://github.com/getdnsapi/getdns.git
Fix gcc 8 warnings.
This commit is contained in:
parent
9024fd7736
commit
09ca9a826b
19
src/anchor.c
19
src/anchor.c
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue