summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn-Mark Bell <jmb@netsurf-browser.org>2021-08-04 18:18:53 +0100
committerJohn-Mark Bell <jmb@netsurf-browser.org>2021-08-04 19:33:26 +0100
commit8c5924c9c23218ea7cbcb90b06c640f85ba7174f (patch)
tree08ff702ae4f05da12a64b0fead2578ef45116cdb /src
parent79795e3a7aca6fc33b40f264c412753acbb4bdf9 (diff)
downloadttf2f-8c5924c9c23218ea7cbcb90b06c640f85ba7174f.tar.gz
ttf2f-8c5924c9c23218ea7cbcb90b06c640f85ba7174f.tar.bz2
Dynamically allocate full path buffer
Diffstat (limited to 'src')
-rw-r--r--src/cli.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/cli.c b/src/cli.c
index 9b31598..307b74f 100644
--- a/src/cli.c
+++ b/src/cli.c
@@ -38,8 +38,8 @@ int main(int argc, char **argv)
ttf2f_ctx ctx;
int fail;
ttf2f_result err = TTF2F_RESULT_OK;
- char *dot, *path;
- char full_path[PATH_MAX]; /* Lazy */
+ char *dot, *path, *full_path = NULL;
+ size_t full_path_len;
if (argc != 4) {
fprintf(stderr,
@@ -104,9 +104,15 @@ int main(int argc, char **argv)
glmetrics(&ctx, progress);
- mkdir(argv[2], 0755);
+ full_path_len = strlen(argv[2]) + strlen(argv[3]) + 2;
+ full_path = malloc(full_path_len);
+ if (full_path == NULL) {
+ fprintf(stderr, "ERROR: no memory for full path\n");
+ goto error_out;
+ }
+ strcpy(full_path, argv[2]);
- strncpy(full_path, argv[2], sizeof(full_path));
+ mkdir(argv[2], 0755);
path = full_path + strlen(full_path);
if (*(path - 1) != *DIR_SEP)
@@ -155,6 +161,9 @@ error_out:
}
}
+ if (full_path != NULL)
+ free(full_path);
+
if (ctx.metrics != NULL) {
free(ctx.metrics->name_copyright);
free(ctx.metrics->name_full);