summaryrefslogtreecommitdiff
path: root/src/cli.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/cli.c')
-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);