diff options
author | Vincent Sanders <vince@kyllikki.org> | 2014-05-11 23:38:18 +0100 |
---|---|---|
committer | Vincent Sanders <vince@kyllikki.org> | 2014-05-11 23:38:18 +0100 |
commit | f94bc67107c9ab1f5816a442a664b0528c735b75 (patch) | |
tree | af5fc0d5b7650264d083eda758e7e84afa08bdbd | |
parent | 4776de40017f67bc2f57a71b3aaea3b69c83c4dc (diff) | |
download | netsurf-f94bc67107c9ab1f5816a442a664b0528c735b75.tar.gz netsurf-f94bc67107c9ab1f5816a442a664b0528c735b75.tar.bz2 |
safely copy header name and author (fixes coverity 1195408)
-rw-r--r-- | utils/container.c | 10 |
1 files changed, 8 insertions, 2 deletions
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) |