Previously, this code was passing string constants to functions that did
not declare their parameters as const. After this patch, the functions now
declare that they do not modify these arguments, making it safe to pass
string constants.

diff --git lib/libc/gen/fts.c lib/libc/gen/fts.c
index d13d0a3f223..dd8f65b02da 100644
--- lib/libc/gen/fts.c
+++ lib/libc/gen/fts.c
@@ -43,7 +43,7 @@

 #define MAXIMUM(a, b)  (((a) > (b)) ? (a) : (b))

-static FTSENT  *fts_alloc(FTS *, char *, size_t);
+static FTSENT  *fts_alloc(FTS *, const char *, size_t);
 static FTSENT  *fts_build(FTS *, int);
 static void     fts_lfree(FTSENT *);
 static void     fts_load(FTS *, FTSENT *);
@@ -52,7 +52,7 @@ static void    fts_padjust(FTS *, FTSENT *);
 static int      fts_palloc(FTS *, size_t);
 static FTSENT  *fts_sort(FTS *, FTSENT *, int);
 static u_short  fts_stat(FTS *, FTSENT *, int, int);
-static int      fts_safe_changedir(FTS *, FTSENT *, int, char *);
+static int      fts_safe_changedir(FTS *, FTSENT *, int, const char *);

 #define        ISDOT(a)        (a[0] == '.' && (!a[1] || (a[1] == '.' &&
!a[2])))

@@ -901,7 +901,7 @@ fts_sort(FTS *sp, FTSENT *head, int nitems)
 }

 static FTSENT *
-fts_alloc(FTS *sp, char *name, size_t namelen)
+fts_alloc(FTS *sp, const char *name, size_t namelen)
 {
        FTSENT *p;
        size_t len;
@@ -1020,7 +1020,7 @@ fts_maxarglen(char * const *argv)
  * Assumes p->fts_dev and p->fts_ino are filled in.
  */
 static int
-fts_safe_changedir(FTS *sp, FTSENT *p, int fd, char *path)
+fts_safe_changedir(FTS *sp, FTSENT *p, int fd, const char *path)
 {
        int ret, oerrno, newfd;
        struct stat sb;

Reply via email to