History log of /netbsd-current/lib/libc/gen/fts.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.52 19-Apr-2022 rillig

lib: remove CONSTCOND comment

Since 2021-01-31, lint doesn't need it anymore for the common pattern of
'do ... while (0)'.


# 1.51 12-Mar-2022 christos

reallocarr returns errno. preserve it.


# 1.50 02-Nov-2021 nia

fts(3): Use reallocarr instead of realloc(x * y), eliminate a temporary
variable.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 netbsd-9-2-RELEASE cjep_staticlib_x-base netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.49 31-May-2016 pgoyette

Use calloc(1, ...) instead of malloc(...) followed immediately by memset()

Addresses PR lib/46818


# 1.48 29-Jan-2015 manu

Fix double free in fts_read()/fts_close()

When fts_read() gets an error on fchdir(), it exited with sp->fts_cur
set to a freed structure. fts_close() would later attempt to free it
again, crashing the program.


# 1.47 18-Sep-2014 christos

make more descriptors that we open as close-on-exec


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 tls-maxphys-base
# 1.46 26-Sep-2012 msaitoh

Fix in comment.


# 1.45 15-Sep-2012 spz

remove dubious cast


Revision tags: yamt-pagecache-base5 yamt-pagecache-base4
# 1.44 14-Mar-2012 christos

branches: 1.44.2;
rename the macros ftsent_ since they apply to the ftsent struct not the
fts one.


# 1.43 13-Mar-2012 christos

PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.42 16-Oct-2011 mrg

branches: 1.42.2;
default O_CLOEXEC to 0 for systems that don't define it, like, say, netbsd-5.


# 1.41 15-Oct-2011 christos

close on exec fixes:
- open + fcntl -> open O_CLOEXEC
- configuration database file descriptors that can stay open are now opened
fopen(db, "re")


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.40 02-Nov-2009 stacktic

Make sure fts_statp is NULL when FTS_NOSTAT is set


# 1.39 16-Aug-2009 christos

Version fts one more time! This is the most versioned API ever... Bump
fts_level from short to int to avoid a potential DoS.
From Maksymilian Arciemowicz


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.38 28-Feb-2009 pgoyette

Avoid possible integer overflow and subsequent collateral damage.
Received from OpenBSD via US-CERT as VU #590371.

Original OpenBSD commit log:

> revision 1.42
> date: 2009/02/11 13:24:05; author: otto; state: Exp; lines: +9 -1
> Avoid level going negative on deep (i mean really deep) dirs. Reported
> by Maksymilian Arciemowicz. ok kettenis@ millert@


# 1.37 03-Feb-2009 lukem

branches: 1.37.2;
fix sign-compare issue


# 1.36 11-Jan-2009 christos

merge christos-time_t


Revision tags: christos-time_t-nbase christos-time_t-base
# 1.35 03-Jan-2009 lukem

Ensure fts_close() doesn't spuriously close fd 0,
by testing FTS_SYMFOLLOW in fts_flags instead of fts_options.
Fix provided by Ben Harris in PR 40319


Revision tags: netbsd-5-base matt-mips64-base2
# 1.34 27-Sep-2008 lukem

branches: 1.34.4; 1.34.6;
fix unused variable if !defined(FTS_ALLOC_ALIGNED)


# 1.33 20-Sep-2008 lukem

Add fts_free() to complement fts_alloc(), and use instead of free().
Should avoid a memory leak on systems without ALIGNBYTES.


Revision tags: wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base keiichi-mipv6-base matt-armv6-nbase
# 1.32 10-Mar-2008 lukem

Style tweaks:
* test defined(HAVE_foo) not just HAVE_foo
* replace u_foo with unsigned foo
* the whitespace change whose name we dare not mention


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base
# 1.31 30-Mar-2006 christos

branches: 1.31.4; 1.31.10; 1.31.14; 1.31.16;
PR/33163: Auster Vl.: fts: cant allocate memory | filename too long
Change the ftp_pathlen and fts_namelen to u_int from u_short so that
pathnames > 32K work.


# 1.30 19-Mar-2006 christos

Coverity CID 17: Free parent if it was not used.


# 1.29 11-Dec-2005 christos

Restore the compatibility versions of fts not to do path mangling (i.e.
remove double slashes). Also make sure we free sp in all cases. From yamt,
many thanks!


# 1.28 18-Nov-2005 christos

ANSI prototypes and function declarations. No functional change.


# 1.27 17-Nov-2005 christos

1. minimize code diffs with FreeBSD
2. return ENAMETOOLONG instead of ENOMEM if name is too long to fit.
3. only decrement cp if we are pointing to the end of the string.
[this fixes the cp truncation of the last char problem reported]


# 1.26 22-Oct-2005 christos

Instead of special-casing root, special case paths that end with a /, so
that find foo/ does not print foo//bar. From FreeBSD.


# 1.25 13-Sep-2005 christos

compat core reorg.


# 1.24 19-Aug-2005 christos

64 bit inode changes


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.23 04-Dec-2003 keihan

netbsd.org -> NetBSD.org
NetBSD.ORG -> NetBSD.org

Now src/lib is done.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 nathanw_sa_end nathanw_sa_before_merge fvdl_fs64_base nathanw_sa_base netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-4-PATCH003 netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.22 22-Oct-1997 thorpej

Allow the old-name functions to be compiled from the same source file as
the renamed functions, and add some #error directives to force the
issue with weak symbols for renamed functions when we support weak
symbols in the C library.


# 1.21 22-Oct-1997 fvdl

New hacks to make libc work painlessly without bumping the major number:
use type func(arg1s) asm("emitted_name") gcc mechanism.
Suggested by Bill Sommerfeld.


Revision tags: netbsd-1-3-base
# 1.20 21-Oct-1997 fvdl

branches: 1.20.2;
Hacks to enable libc to work without bumping the major.


# 1.19 09-Oct-1997 christos

Revert all slash removing changes; it is not worth it...
The latest one broke "ls foo.c/". Sync with Lite-2.


# 1.18 08-Oct-1997 pk

Restore the NAPPEND macro, as it existed until revision 1.13, that deals
with roots consisting of a single slash. This special case of special
cases cannot be dealt with in fts_open() by simply chopping of a
trailing slash.

All this to avoid the occasional doubling of slashes. Oh well..


# 1.17 07-Oct-1997 pk

In fts_alloc() copy the trailing 0 character explicitly, instead of
relying on the passed input string having a 0 character at the right spot.
Takes care of PR#4234.


# 1.16 27-Sep-1997 pk

The change in revision 1.13 to avoid doubling slashes in path names
messes up the internal administrations of the fts engine.

Do this differently by simply stripping one trailing slash (if any)
from root paths passed to fts_open().


# 1.15 21-Jul-1997 jtc

If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.


# 1.14 13-Jul-1997 christos

Fix RCSID's
Add missing prototypes.
Fix rest of gcc warnings.


# 1.13 10-Jul-1997 phil

Fix it so fts_* never adds a / to a path name when there is
already a trailing /. Fixes PR 1495.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.12 27-Feb-1995 cgd

branches: 1.12.4;
merge with Lite, keeping local changes. Also use new Id format.


# 1.11 28-Dec-1994 mycroft

branches: 1.11.2;
Mostly sync with CSRG.


# 1.10 26-Oct-1994 mycroft

Avoid extra stat()s if a link count of 1 is returned for directories but the
d_type field is filled in.


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE netbsd-1-0-base
# 1.9 17-Apr-1994 cgd

POSIXification and bostic's official fix for the missing relative path problem


# 1.8 12-Apr-1994 cgd

re-POSIXIFICATION. should have been punted back to bostic...


# 1.7 12-Apr-1994 cgd

oops, restore bug fix that wasn't fed back to bostic...


# 1.6 12-Apr-1994 cgd

minor fixes


# 1.5 14-Jan-1994 jtc

Fix obscure bug where the working directory would not be restored to its
proper place (occurs if one of fts_open()'s arguments is a relative path
to a empty directory).


# 1.4 24-Nov-1993 jtc

Change C library functions to use strchr() and strrchr() instead of index()
and rindex(). This will allow (strict {ANSI, POSIX, XOPEN}) applications
to redefine index() and rindex() without effecting the library internals.


# 1.3 26-Aug-1993 jtc

Declare rcsid strings so they are stored in text segment.


# 1.2 30-Jul-1993 mycroft

Latest versions from uunet.


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision


# 1.51 12-Mar-2022 christos

reallocarr returns errno. preserve it.


# 1.50 02-Nov-2021 nia

fts(3): Use reallocarr instead of realloc(x * y), eliminate a temporary
variable.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 netbsd-9-2-RELEASE cjep_staticlib_x-base netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.49 31-May-2016 pgoyette

Use calloc(1, ...) instead of malloc(...) followed immediately by memset()

Addresses PR lib/46818


# 1.48 29-Jan-2015 manu

Fix double free in fts_read()/fts_close()

When fts_read() gets an error on fchdir(), it exited with sp->fts_cur
set to a freed structure. fts_close() would later attempt to free it
again, crashing the program.


# 1.47 18-Sep-2014 christos

make more descriptors that we open as close-on-exec


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 tls-maxphys-base
# 1.46 26-Sep-2012 msaitoh

Fix in comment.


# 1.45 15-Sep-2012 spz

remove dubious cast


Revision tags: yamt-pagecache-base5 yamt-pagecache-base4
# 1.44 14-Mar-2012 christos

branches: 1.44.2;
rename the macros ftsent_ since they apply to the ftsent struct not the
fts one.


# 1.43 13-Mar-2012 christos

PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.42 16-Oct-2011 mrg

branches: 1.42.2;
default O_CLOEXEC to 0 for systems that don't define it, like, say, netbsd-5.


# 1.41 15-Oct-2011 christos

close on exec fixes:
- open + fcntl -> open O_CLOEXEC
- configuration database file descriptors that can stay open are now opened
fopen(db, "re")


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.40 02-Nov-2009 stacktic

Make sure fts_statp is NULL when FTS_NOSTAT is set


# 1.39 16-Aug-2009 christos

Version fts one more time! This is the most versioned API ever... Bump
fts_level from short to int to avoid a potential DoS.
From Maksymilian Arciemowicz


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.38 28-Feb-2009 pgoyette

Avoid possible integer overflow and subsequent collateral damage.
Received from OpenBSD via US-CERT as VU #590371.

Original OpenBSD commit log:

> revision 1.42
> date: 2009/02/11 13:24:05; author: otto; state: Exp; lines: +9 -1
> Avoid level going negative on deep (i mean really deep) dirs. Reported
> by Maksymilian Arciemowicz. ok kettenis@ millert@


# 1.37 03-Feb-2009 lukem

branches: 1.37.2;
fix sign-compare issue


# 1.36 11-Jan-2009 christos

merge christos-time_t


Revision tags: christos-time_t-nbase christos-time_t-base
# 1.35 03-Jan-2009 lukem

Ensure fts_close() doesn't spuriously close fd 0,
by testing FTS_SYMFOLLOW in fts_flags instead of fts_options.
Fix provided by Ben Harris in PR 40319


Revision tags: netbsd-5-base matt-mips64-base2
# 1.34 27-Sep-2008 lukem

branches: 1.34.4; 1.34.6;
fix unused variable if !defined(FTS_ALLOC_ALIGNED)


# 1.33 20-Sep-2008 lukem

Add fts_free() to complement fts_alloc(), and use instead of free().
Should avoid a memory leak on systems without ALIGNBYTES.


Revision tags: wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base keiichi-mipv6-base matt-armv6-nbase
# 1.32 10-Mar-2008 lukem

Style tweaks:
* test defined(HAVE_foo) not just HAVE_foo
* replace u_foo with unsigned foo
* the whitespace change whose name we dare not mention


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base
# 1.31 30-Mar-2006 christos

branches: 1.31.4; 1.31.10; 1.31.14; 1.31.16;
PR/33163: Auster Vl.: fts: cant allocate memory | filename too long
Change the ftp_pathlen and fts_namelen to u_int from u_short so that
pathnames > 32K work.


# 1.30 19-Mar-2006 christos

Coverity CID 17: Free parent if it was not used.


# 1.29 11-Dec-2005 christos

Restore the compatibility versions of fts not to do path mangling (i.e.
remove double slashes). Also make sure we free sp in all cases. From yamt,
many thanks!


# 1.28 18-Nov-2005 christos

ANSI prototypes and function declarations. No functional change.


# 1.27 17-Nov-2005 christos

1. minimize code diffs with FreeBSD
2. return ENAMETOOLONG instead of ENOMEM if name is too long to fit.
3. only decrement cp if we are pointing to the end of the string.
[this fixes the cp truncation of the last char problem reported]


# 1.26 22-Oct-2005 christos

Instead of special-casing root, special case paths that end with a /, so
that find foo/ does not print foo//bar. From FreeBSD.


# 1.25 13-Sep-2005 christos

compat core reorg.


# 1.24 19-Aug-2005 christos

64 bit inode changes


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.23 04-Dec-2003 keihan

netbsd.org -> NetBSD.org
NetBSD.ORG -> NetBSD.org

Now src/lib is done.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 nathanw_sa_end nathanw_sa_before_merge fvdl_fs64_base nathanw_sa_base netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-4-PATCH003 netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.22 22-Oct-1997 thorpej

Allow the old-name functions to be compiled from the same source file as
the renamed functions, and add some #error directives to force the
issue with weak symbols for renamed functions when we support weak
symbols in the C library.


# 1.21 22-Oct-1997 fvdl

New hacks to make libc work painlessly without bumping the major number:
use type func(arg1s) asm("emitted_name") gcc mechanism.
Suggested by Bill Sommerfeld.


Revision tags: netbsd-1-3-base
# 1.20 21-Oct-1997 fvdl

branches: 1.20.2;
Hacks to enable libc to work without bumping the major.


# 1.19 09-Oct-1997 christos

Revert all slash removing changes; it is not worth it...
The latest one broke "ls foo.c/". Sync with Lite-2.


# 1.18 08-Oct-1997 pk

Restore the NAPPEND macro, as it existed until revision 1.13, that deals
with roots consisting of a single slash. This special case of special
cases cannot be dealt with in fts_open() by simply chopping of a
trailing slash.

All this to avoid the occasional doubling of slashes. Oh well..


# 1.17 07-Oct-1997 pk

In fts_alloc() copy the trailing 0 character explicitly, instead of
relying on the passed input string having a 0 character at the right spot.
Takes care of PR#4234.


# 1.16 27-Sep-1997 pk

The change in revision 1.13 to avoid doubling slashes in path names
messes up the internal administrations of the fts engine.

Do this differently by simply stripping one trailing slash (if any)
from root paths passed to fts_open().


# 1.15 21-Jul-1997 jtc

If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.


# 1.14 13-Jul-1997 christos

Fix RCSID's
Add missing prototypes.
Fix rest of gcc warnings.


# 1.13 10-Jul-1997 phil

Fix it so fts_* never adds a / to a path name when there is
already a trailing /. Fixes PR 1495.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.12 27-Feb-1995 cgd

branches: 1.12.4;
merge with Lite, keeping local changes. Also use new Id format.


# 1.11 28-Dec-1994 mycroft

branches: 1.11.2;
Mostly sync with CSRG.


# 1.10 26-Oct-1994 mycroft

Avoid extra stat()s if a link count of 1 is returned for directories but the
d_type field is filled in.


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE netbsd-1-0-base
# 1.9 17-Apr-1994 cgd

POSIXification and bostic's official fix for the missing relative path problem


# 1.8 12-Apr-1994 cgd

re-POSIXIFICATION. should have been punted back to bostic...


# 1.7 12-Apr-1994 cgd

oops, restore bug fix that wasn't fed back to bostic...


# 1.6 12-Apr-1994 cgd

minor fixes


# 1.5 14-Jan-1994 jtc

Fix obscure bug where the working directory would not be restored to its
proper place (occurs if one of fts_open()'s arguments is a relative path
to a empty directory).


# 1.4 24-Nov-1993 jtc

Change C library functions to use strchr() and strrchr() instead of index()
and rindex(). This will allow (strict {ANSI, POSIX, XOPEN}) applications
to redefine index() and rindex() without effecting the library internals.


# 1.3 26-Aug-1993 jtc

Declare rcsid strings so they are stored in text segment.


# 1.2 30-Jul-1993 mycroft

Latest versions from uunet.


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision


# 1.50 02-Nov-2021 nia

fts(3): Use reallocarr instead of realloc(x * y), eliminate a temporary
variable.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 netbsd-9-2-RELEASE cjep_staticlib_x-base netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.49 31-May-2016 pgoyette

Use calloc(1, ...) instead of malloc(...) followed immediately by memset()

Addresses PR lib/46818


# 1.48 29-Jan-2015 manu

Fix double free in fts_read()/fts_close()

When fts_read() gets an error on fchdir(), it exited with sp->fts_cur
set to a freed structure. fts_close() would later attempt to free it
again, crashing the program.


# 1.47 18-Sep-2014 christos

make more descriptors that we open as close-on-exec


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 tls-maxphys-base
# 1.46 26-Sep-2012 msaitoh

Fix in comment.


# 1.45 15-Sep-2012 spz

remove dubious cast


Revision tags: yamt-pagecache-base5 yamt-pagecache-base4
# 1.44 14-Mar-2012 christos

branches: 1.44.2;
rename the macros ftsent_ since they apply to the ftsent struct not the
fts one.


# 1.43 13-Mar-2012 christos

PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.42 16-Oct-2011 mrg

branches: 1.42.2;
default O_CLOEXEC to 0 for systems that don't define it, like, say, netbsd-5.


# 1.41 15-Oct-2011 christos

close on exec fixes:
- open + fcntl -> open O_CLOEXEC
- configuration database file descriptors that can stay open are now opened
fopen(db, "re")


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.40 02-Nov-2009 stacktic

Make sure fts_statp is NULL when FTS_NOSTAT is set


# 1.39 16-Aug-2009 christos

Version fts one more time! This is the most versioned API ever... Bump
fts_level from short to int to avoid a potential DoS.
From Maksymilian Arciemowicz


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.38 28-Feb-2009 pgoyette

Avoid possible integer overflow and subsequent collateral damage.
Received from OpenBSD via US-CERT as VU #590371.

Original OpenBSD commit log:

> revision 1.42
> date: 2009/02/11 13:24:05; author: otto; state: Exp; lines: +9 -1
> Avoid level going negative on deep (i mean really deep) dirs. Reported
> by Maksymilian Arciemowicz. ok kettenis@ millert@


# 1.37 03-Feb-2009 lukem

branches: 1.37.2;
fix sign-compare issue


# 1.36 11-Jan-2009 christos

merge christos-time_t


Revision tags: christos-time_t-nbase christos-time_t-base
# 1.35 03-Jan-2009 lukem

Ensure fts_close() doesn't spuriously close fd 0,
by testing FTS_SYMFOLLOW in fts_flags instead of fts_options.
Fix provided by Ben Harris in PR 40319


Revision tags: netbsd-5-base matt-mips64-base2
# 1.34 27-Sep-2008 lukem

branches: 1.34.4; 1.34.6;
fix unused variable if !defined(FTS_ALLOC_ALIGNED)


# 1.33 20-Sep-2008 lukem

Add fts_free() to complement fts_alloc(), and use instead of free().
Should avoid a memory leak on systems without ALIGNBYTES.


Revision tags: wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base keiichi-mipv6-base matt-armv6-nbase
# 1.32 10-Mar-2008 lukem

Style tweaks:
* test defined(HAVE_foo) not just HAVE_foo
* replace u_foo with unsigned foo
* the whitespace change whose name we dare not mention


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base
# 1.31 30-Mar-2006 christos

branches: 1.31.4; 1.31.10; 1.31.14; 1.31.16;
PR/33163: Auster Vl.: fts: cant allocate memory | filename too long
Change the ftp_pathlen and fts_namelen to u_int from u_short so that
pathnames > 32K work.


# 1.30 19-Mar-2006 christos

Coverity CID 17: Free parent if it was not used.


# 1.29 11-Dec-2005 christos

Restore the compatibility versions of fts not to do path mangling (i.e.
remove double slashes). Also make sure we free sp in all cases. From yamt,
many thanks!


# 1.28 18-Nov-2005 christos

ANSI prototypes and function declarations. No functional change.


# 1.27 17-Nov-2005 christos

1. minimize code diffs with FreeBSD
2. return ENAMETOOLONG instead of ENOMEM if name is too long to fit.
3. only decrement cp if we are pointing to the end of the string.
[this fixes the cp truncation of the last char problem reported]


# 1.26 22-Oct-2005 christos

Instead of special-casing root, special case paths that end with a /, so
that find foo/ does not print foo//bar. From FreeBSD.


# 1.25 13-Sep-2005 christos

compat core reorg.


# 1.24 19-Aug-2005 christos

64 bit inode changes


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.23 04-Dec-2003 keihan

netbsd.org -> NetBSD.org
NetBSD.ORG -> NetBSD.org

Now src/lib is done.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 nathanw_sa_end nathanw_sa_before_merge fvdl_fs64_base nathanw_sa_base netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-4-PATCH003 netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.22 22-Oct-1997 thorpej

Allow the old-name functions to be compiled from the same source file as
the renamed functions, and add some #error directives to force the
issue with weak symbols for renamed functions when we support weak
symbols in the C library.


# 1.21 22-Oct-1997 fvdl

New hacks to make libc work painlessly without bumping the major number:
use type func(arg1s) asm("emitted_name") gcc mechanism.
Suggested by Bill Sommerfeld.


Revision tags: netbsd-1-3-base
# 1.20 21-Oct-1997 fvdl

branches: 1.20.2;
Hacks to enable libc to work without bumping the major.


# 1.19 09-Oct-1997 christos

Revert all slash removing changes; it is not worth it...
The latest one broke "ls foo.c/". Sync with Lite-2.


# 1.18 08-Oct-1997 pk

Restore the NAPPEND macro, as it existed until revision 1.13, that deals
with roots consisting of a single slash. This special case of special
cases cannot be dealt with in fts_open() by simply chopping of a
trailing slash.

All this to avoid the occasional doubling of slashes. Oh well..


# 1.17 07-Oct-1997 pk

In fts_alloc() copy the trailing 0 character explicitly, instead of
relying on the passed input string having a 0 character at the right spot.
Takes care of PR#4234.


# 1.16 27-Sep-1997 pk

The change in revision 1.13 to avoid doubling slashes in path names
messes up the internal administrations of the fts engine.

Do this differently by simply stripping one trailing slash (if any)
from root paths passed to fts_open().


# 1.15 21-Jul-1997 jtc

If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.


# 1.14 13-Jul-1997 christos

Fix RCSID's
Add missing prototypes.
Fix rest of gcc warnings.


# 1.13 10-Jul-1997 phil

Fix it so fts_* never adds a / to a path name when there is
already a trailing /. Fixes PR 1495.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.12 27-Feb-1995 cgd

branches: 1.12.4;
merge with Lite, keeping local changes. Also use new Id format.


# 1.11 28-Dec-1994 mycroft

branches: 1.11.2;
Mostly sync with CSRG.


# 1.10 26-Oct-1994 mycroft

Avoid extra stat()s if a link count of 1 is returned for directories but the
d_type field is filled in.


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE netbsd-1-0-base
# 1.9 17-Apr-1994 cgd

POSIXification and bostic's official fix for the missing relative path problem


# 1.8 12-Apr-1994 cgd

re-POSIXIFICATION. should have been punted back to bostic...


# 1.7 12-Apr-1994 cgd

oops, restore bug fix that wasn't fed back to bostic...


# 1.6 12-Apr-1994 cgd

minor fixes


# 1.5 14-Jan-1994 jtc

Fix obscure bug where the working directory would not be restored to its
proper place (occurs if one of fts_open()'s arguments is a relative path
to a empty directory).


# 1.4 24-Nov-1993 jtc

Change C library functions to use strchr() and strrchr() instead of index()
and rindex(). This will allow (strict {ANSI, POSIX, XOPEN}) applications
to redefine index() and rindex() without effecting the library internals.


# 1.3 26-Aug-1993 jtc

Declare rcsid strings so they are stored in text segment.


# 1.2 30-Jul-1993 mycroft

Latest versions from uunet.


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision


Revision tags: pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.49 31-May-2016 pgoyette

Use calloc(1, ...) instead of malloc(...) followed immediately by memset()

Addresses PR lib/46818


# 1.48 29-Jan-2015 manu

Fix double free in fts_read()/fts_close()

When fts_read() gets an error on fchdir(), it exited with sp->fts_cur
set to a freed structure. fts_close() would later attempt to free it
again, crashing the program.


# 1.47 18-Sep-2014 christos

make more descriptors that we open as close-on-exec


Revision tags: netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 tls-maxphys-base
# 1.46 26-Sep-2012 msaitoh

Fix in comment.


# 1.45 15-Sep-2012 spz

remove dubious cast


Revision tags: yamt-pagecache-base5 yamt-pagecache-base4
# 1.44 14-Mar-2012 christos

branches: 1.44.2;
rename the macros ftsent_ since they apply to the ftsent struct not the
fts one.


# 1.43 13-Mar-2012 christos

PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.42 16-Oct-2011 mrg

branches: 1.42.2;
default O_CLOEXEC to 0 for systems that don't define it, like, say, netbsd-5.


# 1.41 15-Oct-2011 christos

close on exec fixes:
- open + fcntl -> open O_CLOEXEC
- configuration database file descriptors that can stay open are now opened
fopen(db, "re")


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.40 02-Nov-2009 stacktic

Make sure fts_statp is NULL when FTS_NOSTAT is set


# 1.39 16-Aug-2009 christos

Version fts one more time! This is the most versioned API ever... Bump
fts_level from short to int to avoid a potential DoS.
From Maksymilian Arciemowicz


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.38 28-Feb-2009 pgoyette

Avoid possible integer overflow and subsequent collateral damage.
Received from OpenBSD via US-CERT as VU #590371.

Original OpenBSD commit log:

> revision 1.42
> date: 2009/02/11 13:24:05; author: otto; state: Exp; lines: +9 -1
> Avoid level going negative on deep (i mean really deep) dirs. Reported
> by Maksymilian Arciemowicz. ok kettenis@ millert@


# 1.37 03-Feb-2009 lukem

branches: 1.37.2;
fix sign-compare issue


# 1.36 11-Jan-2009 christos

merge christos-time_t


Revision tags: christos-time_t-nbase christos-time_t-base
# 1.35 03-Jan-2009 lukem

Ensure fts_close() doesn't spuriously close fd 0,
by testing FTS_SYMFOLLOW in fts_flags instead of fts_options.
Fix provided by Ben Harris in PR 40319


Revision tags: netbsd-5-base matt-mips64-base2
# 1.34 27-Sep-2008 lukem

branches: 1.34.4; 1.34.6;
fix unused variable if !defined(FTS_ALLOC_ALIGNED)


# 1.33 20-Sep-2008 lukem

Add fts_free() to complement fts_alloc(), and use instead of free().
Should avoid a memory leak on systems without ALIGNBYTES.


Revision tags: wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base keiichi-mipv6-base matt-armv6-nbase
# 1.32 10-Mar-2008 lukem

Style tweaks:
* test defined(HAVE_foo) not just HAVE_foo
* replace u_foo with unsigned foo
* the whitespace change whose name we dare not mention


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base
# 1.31 30-Mar-2006 christos

branches: 1.31.4; 1.31.10; 1.31.14; 1.31.16;
PR/33163: Auster Vl.: fts: cant allocate memory | filename too long
Change the ftp_pathlen and fts_namelen to u_int from u_short so that
pathnames > 32K work.


# 1.30 19-Mar-2006 christos

Coverity CID 17: Free parent if it was not used.


# 1.29 11-Dec-2005 christos

Restore the compatibility versions of fts not to do path mangling (i.e.
remove double slashes). Also make sure we free sp in all cases. From yamt,
many thanks!


# 1.28 18-Nov-2005 christos

ANSI prototypes and function declarations. No functional change.


# 1.27 17-Nov-2005 christos

1. minimize code diffs with FreeBSD
2. return ENAMETOOLONG instead of ENOMEM if name is too long to fit.
3. only decrement cp if we are pointing to the end of the string.
[this fixes the cp truncation of the last char problem reported]


# 1.26 22-Oct-2005 christos

Instead of special-casing root, special case paths that end with a /, so
that find foo/ does not print foo//bar. From FreeBSD.


# 1.25 13-Sep-2005 christos

compat core reorg.


# 1.24 19-Aug-2005 christos

64 bit inode changes


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.23 04-Dec-2003 keihan

netbsd.org -> NetBSD.org
NetBSD.ORG -> NetBSD.org

Now src/lib is done.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 nathanw_sa_end nathanw_sa_before_merge fvdl_fs64_base nathanw_sa_base netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-4-PATCH003 netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.22 22-Oct-1997 thorpej

Allow the old-name functions to be compiled from the same source file as
the renamed functions, and add some #error directives to force the
issue with weak symbols for renamed functions when we support weak
symbols in the C library.


# 1.21 22-Oct-1997 fvdl

New hacks to make libc work painlessly without bumping the major number:
use type func(arg1s) asm("emitted_name") gcc mechanism.
Suggested by Bill Sommerfeld.


Revision tags: netbsd-1-3-base
# 1.20 21-Oct-1997 fvdl

branches: 1.20.2;
Hacks to enable libc to work without bumping the major.


# 1.19 09-Oct-1997 christos

Revert all slash removing changes; it is not worth it...
The latest one broke "ls foo.c/". Sync with Lite-2.


# 1.18 08-Oct-1997 pk

Restore the NAPPEND macro, as it existed until revision 1.13, that deals
with roots consisting of a single slash. This special case of special
cases cannot be dealt with in fts_open() by simply chopping of a
trailing slash.

All this to avoid the occasional doubling of slashes. Oh well..


# 1.17 07-Oct-1997 pk

In fts_alloc() copy the trailing 0 character explicitly, instead of
relying on the passed input string having a 0 character at the right spot.
Takes care of PR#4234.


# 1.16 27-Sep-1997 pk

The change in revision 1.13 to avoid doubling slashes in path names
messes up the internal administrations of the fts engine.

Do this differently by simply stripping one trailing slash (if any)
from root paths passed to fts_open().


# 1.15 21-Jul-1997 jtc

If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.


# 1.14 13-Jul-1997 christos

Fix RCSID's
Add missing prototypes.
Fix rest of gcc warnings.


# 1.13 10-Jul-1997 phil

Fix it so fts_* never adds a / to a path name when there is
already a trailing /. Fixes PR 1495.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.12 27-Feb-1995 cgd

branches: 1.12.4;
merge with Lite, keeping local changes. Also use new Id format.


# 1.11 28-Dec-1994 mycroft

branches: 1.11.2;
Mostly sync with CSRG.


# 1.10 26-Oct-1994 mycroft

Avoid extra stat()s if a link count of 1 is returned for directories but the
d_type field is filled in.


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE netbsd-1-0-base
# 1.9 17-Apr-1994 cgd

POSIXification and bostic's official fix for the missing relative path problem


# 1.8 12-Apr-1994 cgd

re-POSIXIFICATION. should have been punted back to bostic...


# 1.7 12-Apr-1994 cgd

oops, restore bug fix that wasn't fed back to bostic...


# 1.6 12-Apr-1994 cgd

minor fixes


# 1.5 14-Jan-1994 jtc

Fix obscure bug where the working directory would not be restored to its
proper place (occurs if one of fts_open()'s arguments is a relative path
to a empty directory).


# 1.4 24-Nov-1993 jtc

Change C library functions to use strchr() and strrchr() instead of index()
and rindex(). This will allow (strict {ANSI, POSIX, XOPEN}) applications
to redefine index() and rindex() without effecting the library internals.


# 1.3 26-Aug-1993 jtc

Declare rcsid strings so they are stored in text segment.


# 1.2 30-Jul-1993 mycroft

Latest versions from uunet.


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision