logo

oasis

Own branch of Oasis Linux (upstream: <https://git.sr.ht/~mcf/oasis/>) git clone https://anongit.hacktivis.me/git/oasis.git

0003-Avoid-unnecessary-VLA.patch (1098B)


  1. From 4e30a1cc8fb347d24861fd1a702c56b5644b9431 Mon Sep 17 00:00:00 2001
  2. From: Michael Forney <mforney@mforney.org>
  3. Date: Fri, 30 Apr 2021 19:43:25 -0700
  4. Subject: [PATCH] Avoid unnecessary VLA
  5. This VLA has a constant size, so just use a regular array instead.
  6. ---
  7. inotify_handler.c | 5 ++---
  8. 1 file changed, 2 insertions(+), 3 deletions(-)
  9. diff --git a/inotify_handler.c b/inotify_handler.c
  10. index bb4ee14..ea64955 100644
  11. --- a/inotify_handler.c
  12. +++ b/inotify_handler.c
  13. @@ -67,8 +67,7 @@ static void process_inotify(int fd)
  14. return;
  15. }
  16. - const int dnsize = NAME_MAX + 1;
  17. - char devname[dnsize];
  18. + char devname[NAME_MAX + 1];
  19. /* while there are still messages in eventbuf */
  20. while (processed_bytes < bytes) {
  21. @@ -82,7 +81,7 @@ static void process_inotify(int fd)
  22. /* devname = ACPID_INPUTLAYERDIR + "/" + pevent -> name */
  23. strcpy(devname, ACPID_INPUTLAYERDIR);
  24. strcat(devname, "/");
  25. - strncat(devname, curevent->name, dnsize - strlen(devname) - 1);
  26. + strncat(devname, curevent->name, sizeof(devname) - strlen(devname) - 1);
  27. }
  28. /* if this is a create */
  29. --
  30. 2.31.1