logo

oasis

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

0008-Avoid-unnecessary-VLAs.patch (1457B)


  1. From ab8a58c777d6bc3e33b1f28c80fa5bbada804a4b Mon Sep 17 00:00:00 2001
  2. From: Michael Forney <mforney@mforney.org>
  3. Date: Sun, 16 Jun 2019 13:38:59 -0700
  4. Subject: [PATCH] Avoid unnecessary VLAs
  5. ---
  6. include/bpf_scm.h | 2 +-
  7. ip/iptuntap.c | 5 ++---
  8. 2 files changed, 3 insertions(+), 4 deletions(-)
  9. diff --git a/include/bpf_scm.h b/include/bpf_scm.h
  10. index 669f0538..9e456030 100644
  11. --- a/include/bpf_scm.h
  12. +++ b/include/bpf_scm.h
  13. @@ -37,7 +37,7 @@ static inline int *bpf_map_set_init(struct bpf_map_set_msg *msg,
  14. struct sockaddr_un *addr,
  15. unsigned int addr_len)
  16. {
  17. - const unsigned int cmsg_ctl_len = sizeof(int) * BPF_SCM_MAX_FDS;
  18. + enum { cmsg_ctl_len = sizeof(int) * BPF_SCM_MAX_FDS };
  19. struct cmsghdr *cmsg;
  20. msg->iov.iov_base = &msg->aux;
  21. diff --git a/ip/iptuntap.c b/ip/iptuntap.c
  22. index 3cf55055..e149ae16 100644
  23. --- a/ip/iptuntap.c
  24. +++ b/ip/iptuntap.c
  25. @@ -270,8 +270,7 @@ static void show_processes(const char *name)
  26. fd_path = globbuf.gl_pathv;
  27. while (*fd_path) {
  28. - const size_t linkbuf_len = strlen(TUNDEV) + 2;
  29. - char linkbuf[linkbuf_len], *fdinfo;
  30. + char linkbuf[sizeof(TUNDEV) + 1], *fdinfo;
  31. int pid, fd;
  32. FILE *f;
  33. @@ -281,7 +280,7 @@ static void show_processes(const char *name)
  34. if (pid == getpid())
  35. goto next;
  36. - err = readlink(*fd_path, linkbuf, linkbuf_len - 1);
  37. + err = readlink(*fd_path, linkbuf, sizeof(linkbuf) - 1);
  38. if (err < 0) {
  39. perror("readlink");
  40. goto next;
  41. --
  42. 2.44.0