logo

oasis

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

0001-fts-Avoid-d_namlen.patch (1538B)


  1. From b546a0ae0beb2323143aed00d05e2fdf4fef5239 Mon Sep 17 00:00:00 2001
  2. From: Michael Forney <mforney@mforney.org>
  3. Date: Sun, 17 Apr 2016 23:50:15 -0700
  4. Subject: [PATCH] fts: Avoid d_namlen
  5. ---
  6. lib/libc/gen/fts.c | 10 ++++++----
  7. 1 file changed, 6 insertions(+), 4 deletions(-)
  8. diff --git a/lib/libc/gen/fts.c b/lib/libc/gen/fts.c
  9. index 98b3a0a39..c186b7af2 100644
  10. --- a/lib/libc/gen/fts.c
  11. +++ b/lib/libc/gen/fts.c
  12. @@ -555,6 +555,7 @@ fts_build(FTS *sp, int type)
  13. int nitems, cderrno, descend, level, nlinks, nostat, doadjust;
  14. int saved_errno;
  15. char *cp;
  16. + size_t namlen;
  17. /* Set current node pointer. */
  18. cur = sp->fts_cur;
  19. @@ -653,11 +654,12 @@ fts_build(FTS *sp, int type)
  20. if (!ISSET(FTS_SEEDOT) && ISDOT(dp->d_name))
  21. continue;
  22. - if (!(p = fts_alloc(sp, dp->d_name, dp->d_namlen)))
  23. + namlen = strlen(dp->d_name);
  24. + if (!(p = fts_alloc(sp, dp->d_name, namlen)))
  25. goto mem1;
  26. - if (dp->d_namlen >= maxlen) { /* include space for NUL */
  27. + if (namlen >= maxlen) { /* include space for NUL */
  28. oldaddr = sp->fts_path;
  29. - if (fts_palloc(sp, dp->d_namlen +len + 1)) {
  30. + if (fts_palloc(sp, namlen +len + 1)) {
  31. /*
  32. * No more memory for path or structures. Save
  33. * errno, free up the current structure and the
  34. @@ -683,7 +685,7 @@ mem1: saved_errno = errno;
  35. p->fts_level = level;
  36. p->fts_parent = sp->fts_cur;
  37. - p->fts_pathlen = len + dp->d_namlen;
  38. + p->fts_pathlen = len + namlen;
  39. if (p->fts_pathlen < len) {
  40. /*
  41. * If we wrap, free up the current structure and
  42. --
  43. 2.12.2