safely copy header name and author (fixes coverity 1195408)

This commit is contained in:
Vincent Sanders 2014-05-11 23:38:18 +01:00
parent 4776de4001
commit f94bc67107
1 changed files with 8 additions and 2 deletions

View File

@ -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)