Fix for gcc 8.2 warnings.

Replace strncat with memcpy to placate gcc 8.2.
Also fix issue in tempfileplus.

Issue #192.
This commit is contained in:
John McNamara 2018-08-22 20:52:12 +01:00
parent d4819bc3a3
commit 4310da6075
2 changed files with 8 additions and 8 deletions

View file

@ -153,19 +153,19 @@ _escape_attributes(struct xml_attribute *attribute)
while (*p_attr) {
switch (*p_attr) {
case '&':
strncat(p_encoded, LXW_AMP, sizeof(LXW_AMP) - 1);
memcpy(p_encoded, LXW_AMP, sizeof(LXW_AMP) - 1);
p_encoded += sizeof(LXW_AMP) - 1;
break;
case '<':
strncat(p_encoded, LXW_LT, sizeof(LXW_LT) - 1);
memcpy(p_encoded, LXW_LT, sizeof(LXW_LT) - 1);
p_encoded += sizeof(LXW_LT) - 1;
break;
case '>':
strncat(p_encoded, LXW_GT, sizeof(LXW_GT) - 1);
memcpy(p_encoded, LXW_GT, sizeof(LXW_GT) - 1);
p_encoded += sizeof(LXW_GT) - 1;
break;
case '"':
strncat(p_encoded, LXW_QUOT, sizeof(LXW_QUOT) - 1);
memcpy(p_encoded, LXW_QUOT, sizeof(LXW_QUOT) - 1);
p_encoded += sizeof(LXW_QUOT) - 1;
break;
default:
@ -195,15 +195,15 @@ lxw_escape_data(const char *data)
while (*data) {
switch (*data) {
case '&':
strncat(p_encoded, LXW_AMP, sizeof(LXW_AMP) - 1);
memcpy(p_encoded, LXW_AMP, sizeof(LXW_AMP) - 1);
p_encoded += sizeof(LXW_AMP) - 1;
break;
case '<':
strncat(p_encoded, LXW_LT, sizeof(LXW_LT) - 1);
memcpy(p_encoded, LXW_LT, sizeof(LXW_LT) - 1);
p_encoded += sizeof(LXW_LT) - 1;
break;
case '>':
strncat(p_encoded, LXW_GT, sizeof(LXW_GT) - 1);
memcpy(p_encoded, LXW_GT, sizeof(LXW_GT) - 1);
p_encoded += sizeof(LXW_GT) - 1;
break;
default:

View file

@ -169,7 +169,7 @@ static char *getenv_save(const char *varname, char *buf, size_t bufsize)
buf[0] = '\0';
if (ptr)
{
strncpy(buf, ptr, bufsize);
strncpy(buf, ptr, bufsize-1);
buf[bufsize-1] = '\0';
return buf;
}