Skip to content

Commit 6d68884

Browse files
committed
Fix gcc warning about Wstringop-truncation
1 parent a439970 commit 6d68884

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

audisp/test/test-queue.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,8 @@ static event_t *make_event(const char *str)
2222
e->hdr.ver = AUDISP_PROTOCOL_VER;
2323
e->hdr.hlen = sizeof(struct audit_dispatcher_header);
2424
e->hdr.type = 0;
25-
e->hdr.size = strlen(str);
26-
if (e->hdr.size >= MAX_AUDIT_MESSAGE_LENGTH)
27-
e->hdr.size = MAX_AUDIT_MESSAGE_LENGTH - 1;
28-
strncpy(e->data, str, e->hdr.size);
25+
e->hdr.size = strnlen(str, MAX_AUDIT_MESSAGE_LENGTH - 1);
26+
memcpy(e->data, str, e->hdr.size);
2927
e->data[e->hdr.size] = '\0';
3028
return e;
3129
}

0 commit comments

Comments
 (0)