From f94bc67107c9ab1f5816a442a664b0528c735b75 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Sun, 11 May 2014 23:38:18 +0100 Subject: safely copy header name and author (fixes coverity 1195408) --- utils/container.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'utils/container.c') diff --git a/utils/container.c b/utils/container.c index 016ba153c..adf72b78e 100644 --- a/utils/container.c +++ b/utils/container.c @@ -322,8 +322,14 @@ struct container_ctx *container_create(const char *filename, ctx->entries = 0; ctx->directory = NULL; ctx->header.parser = htonl(3); - strncpy((char *)ctx->header.name, (char *)name, 32); - strncpy((char *)ctx->header.author, (char *)author, 64); + + snprintf((char *)ctx->header.name, + sizeof(ctx->header.name), + "%s", (char *)name); + + snprintf((char *)ctx->header.author, + sizeof(ctx->header.author), + "%s", (char *)author); val = fwrite("NSTM", 4, 1, ctx->fh); if (val == 0) -- cgit v1.2.3