0001-Use-static-buffer-for-default-sigfile-path.patch (1327B)
- From 2ae5ef7e311782bffb5c68b7aaceb98086352ece Mon Sep 17 00:00:00 2001
- From: "Haelwenn (lanodan) Monnier" <contact@hacktivis.me>
- Date: Sun, 5 Oct 2025 21:29:44 +0200
- Subject: [PATCH] Use static buffer for default sigfile path
- ---
- main.c | 16 +++++++++++++---
- 1 file changed, 13 insertions(+), 3 deletions(-)
- diff --git a/main.c b/main.c
- index ebfdfb0..addbfb8 100644
- --- a/main.c
- +++ b/main.c
- @@ -26,11 +26,16 @@
- #include <fcntl.h>
- #include <unistd.h>
- #include <inttypes.h>
- +#include <limits.h>
- #include "base64.h"
- #include "edsign.h"
- #include "ed25519.h"
- +#ifndef PATH_MAX
- +#define PATH_MAX 4096
- +#endif
- +
- struct pubkey {
- char pkalg[2];
- uint8_t fingerprint[8];
- @@ -409,14 +414,19 @@ int main(int argc, char **argv)
- }
- if (!sigfile && msgfile) {
- - char *buf = alloca(strlen(msgfile) + 5);
- -
- if (!strcmp(msgfile, "-")) {
- fprintf(stderr, "Need signature file when reading message from stdin\n");
- return 1;
- }
- - sprintf(buf, "%s.sig", msgfile);
- + if ((strlen(msgfile) - 4) > PATH_MAX)
- + {
- + fprintf(stderr, "Need signature file when msgfile path is over %zd (PATH_MAX - 4)\n", (size_t)PATH_MAX);
- + return 1;
- + }
- +
- + static char buf[PATH_MAX];
- + snprintf(buf, PATH_MAX, "%s.sig", msgfile);
- sigfile = buf;
- }
- base-commit: f1f65026a94137c91b5466b149ef3ea3f20091e9
- --
- 2.49.1