Skip to content

Commit 2b5b43b

Browse files
committed
xplist: Use memcpy instead of strncpy since we know the exact size
1 parent ac7b641 commit 2b5b43b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/xplist.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -979,7 +979,7 @@ static char* text_parts_get_content(text_part_t *tp, int unesc_entities, size_t
979979
tp = tmp;
980980
while (tp && tp->begin) {
981981
size_t len = tp->length;
982-
strncpy(p, tp->begin, len);
982+
memcpy(p, tp->begin, len);
983983
p[len] = '\0';
984984
if (!tp->is_cdata && unesc_entities) {
985985
if (unescape_entities(p, &len) < 0) {
@@ -1110,7 +1110,7 @@ static plist_err_t node_from_xml(parse_ctx ctx, plist_t *plist)
11101110
}
11111111
size_t taglen = ctx->pos - p;
11121112
tag = (char*)malloc(taglen + 1);
1113-
strncpy(tag, p, taglen);
1113+
memcpy(tag, p, taglen);
11141114
tag[taglen] = '\0';
11151115
if (*ctx->pos != '>') {
11161116
find_next(ctx, "<>", 2, 1);
@@ -1386,7 +1386,7 @@ static plist_err_t node_from_xml(parse_ctx ctx, plist_t *plist)
13861386
/* we need to copy here and 0-terminate because sscanf will read the entire string (whole rest of XML data) which can be huge */
13871387
char strval[32];
13881388
struct TM btime;
1389-
strncpy(strval, str_content, length);
1389+
memcpy(strval, str_content, length);
13901390
strval[tp->length] = '\0';
13911391
parse_date(strval, &btime);
13921392
timev = timegm64(&btime);

0 commit comments

Comments
 (0)