diff options
| author | Joseph Hunkeler <jhunkeler@gmail.com> | 2026-04-22 16:04:02 -0400 |
|---|---|---|
| committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2026-04-22 16:04:02 -0400 |
| commit | a009035b2744be16836aebd81c18bb1a437d236e (patch) | |
| tree | 58d8e2c4829f8bb5b3b4aebc9991ba0da38bf9cc /src/lib/delivery | |
| parent | 2a8db73a10373d858df6ef026811047bfbf4083f (diff) | |
| download | stasis-a009035b2744be16836aebd81c18bb1a437d236e.tar.gz | |
Use snprintf
Diffstat (limited to 'src/lib/delivery')
| -rw-r--r-- | src/lib/delivery/delivery_docker.c | 4 | ||||
| -rw-r--r-- | src/lib/delivery/delivery_install.c | 6 |
2 files changed, 5 insertions, 5 deletions
diff --git a/src/lib/delivery/delivery_docker.c b/src/lib/delivery/delivery_docker.c index e5f1c2f..6aa977a 100644 --- a/src/lib/delivery/delivery_docker.c +++ b/src/lib/delivery/delivery_docker.c @@ -49,7 +49,7 @@ int delivery_docker(struct Delivery *ctx) { const char *tag_fmt = " -t \"%s\" "; const int tag_fmt_len = snprintf(NULL, 0, tag_fmt, tag); - snprintf(args + strlen(args), tag_fmt_len, tag_fmt, tag); + snprintf(args + strlen(args), sizeof(args) - strlen(args) - tag_fmt_len, tag_fmt, tag); } // Append build arguments to command (i.e. --build-arg "key=value" @@ -61,7 +61,7 @@ int delivery_docker(struct Delivery *ctx) { const char *build_arg_fmt = " --build-arg \"%s\" "; const int build_arg_fmt_len = snprintf(NULL, 0, build_arg_fmt, build_arg); - snprintf(args + strlen(args), sizeof(args) - build_arg_fmt_len, build_arg_fmt, build_arg); + snprintf(args + strlen(args), sizeof(args) - strlen(args) - build_arg_fmt_len, build_arg_fmt, build_arg); } // Build the image diff --git a/src/lib/delivery/delivery_install.c b/src/lib/delivery/delivery_install.c index 51b78fa..26bd98f 100644 --- a/src/lib/delivery/delivery_install.c +++ b/src/lib/delivery/delivery_install.c @@ -320,7 +320,7 @@ int delivery_install_packages(struct Delivery *ctx, char *conda_install_dir, cha return -1; } } - snprintf(args + strlen(args), required_len + 1, fmt, req, info->version); + snprintf(args + strlen(args), sizeof(args) - strlen(args) - required_len + 1, fmt, req, info->version); } else { fprintf(stderr, "Deferred package '%s' is not present in the tested package list!\n", name); guard_free(args); @@ -338,7 +338,7 @@ int delivery_install_packages(struct Delivery *ctx, char *conda_install_dir, cha return -1; } } - snprintf(args + strlen(args), required_len + 1, fmt, name); + snprintf(args + strlen(args), sizeof(args) - strlen(args) - required_len + 1, fmt, name); } else { const char *fmt_append = "%s '%s'"; const char *fmt = " '%s'"; @@ -350,7 +350,7 @@ int delivery_install_packages(struct Delivery *ctx, char *conda_install_dir, cha return -1; } } - snprintf(args + strlen(args), required_len + 1, fmt, name); + snprintf(args + strlen(args), sizeof(args) - strlen(args) - required_len + 1, fmt, name); } } } |
