logo

bootstrap-initrd

Linux initrd to bootstrap from a small binary seed git clone https://anongit.hacktivis.me/git/bootstrap-initrd.git/

0001-Use-static-buffer-for-default-sigfile-path.patch (1327B)


  1. From 2ae5ef7e311782bffb5c68b7aaceb98086352ece Mon Sep 17 00:00:00 2001
  2. From: "Haelwenn (lanodan) Monnier" <contact@hacktivis.me>
  3. Date: Sun, 5 Oct 2025 21:29:44 +0200
  4. Subject: [PATCH] Use static buffer for default sigfile path
  5. ---
  6. main.c | 16 +++++++++++++---
  7. 1 file changed, 13 insertions(+), 3 deletions(-)
  8. diff --git a/main.c b/main.c
  9. index ebfdfb0..addbfb8 100644
  10. --- a/main.c
  11. +++ b/main.c
  12. @@ -26,11 +26,16 @@
  13. #include <fcntl.h>
  14. #include <unistd.h>
  15. #include <inttypes.h>
  16. +#include <limits.h>
  17. #include "base64.h"
  18. #include "edsign.h"
  19. #include "ed25519.h"
  20. +#ifndef PATH_MAX
  21. +#define PATH_MAX 4096
  22. +#endif
  23. +
  24. struct pubkey {
  25. char pkalg[2];
  26. uint8_t fingerprint[8];
  27. @@ -409,14 +414,19 @@ int main(int argc, char **argv)
  28. }
  29. if (!sigfile && msgfile) {
  30. - char *buf = alloca(strlen(msgfile) + 5);
  31. -
  32. if (!strcmp(msgfile, "-")) {
  33. fprintf(stderr, "Need signature file when reading message from stdin\n");
  34. return 1;
  35. }
  36. - sprintf(buf, "%s.sig", msgfile);
  37. + if ((strlen(msgfile) - 4) > PATH_MAX)
  38. + {
  39. + fprintf(stderr, "Need signature file when msgfile path is over %zd (PATH_MAX - 4)\n", (size_t)PATH_MAX);
  40. + return 1;
  41. + }
  42. +
  43. + static char buf[PATH_MAX];
  44. + snprintf(buf, PATH_MAX, "%s.sig", msgfile);
  45. sigfile = buf;
  46. }
  47. base-commit: f1f65026a94137c91b5466b149ef3ea3f20091e9
  48. --
  49. 2.49.1