On Thu, 18 Jan 2007, J.C. Roberts wrote: > Hi Otto, > > I'm working on arj/unarj ports for use with clamav, and I'm struggling > to regain all the things I've forgotten about C. ;-) While searching > the archives, I stumbled across this tread from a couple weeks ago but > I'm still wondering if I've got the right idea... > > <stdio.h> > #define FILENAME_MAX 1024 /* must be <= PATH_MAX > <sys/syslimits.h> */ > > <sys/syslimits.h> > #define NAME_MAX 255 /* max bytes in a file name */ > #define PATH_MAX 1024 /* max bytes in pathname */ > > If I understand things correctly: > -A fully qualified path including file name (i.e. canonical path) can > not exceed 1024 bytes. > -The file name itself (without path) can not exceed 255 bytes.
Yeah, that's correct. FILENAME_MAX is actually a path limit with a confusing name. On POSIX systems, please use NAME_MAX and PATH_MAX. NAME_MAX does NOT include the terminating NUL, PATH_MAX DOES include the terminating NUL. See http://www.opengroup.org/onlinepubs/009695399/basedefs/limits.h.html. Since dirs are also files, NAME_MAX holds for any component of a path. > > It's systrace not capable of allocating mem for the args to > > rename(2). The args are replaced by their canonical path (which is > > absolute and thus quite long) and systrace uses the stackgap of 512 > > bytes for that. Obviously two path names of each more than 300 chars > > won't fit. > If the limit on a canonical path is 1024 bytes and you need two such > paths/strings for rename(2), then the result is you need 2048 bytes > available and the 512 byte limit of the stackgap should be considered a > bug. It seems you can't use systrace with the system as it's #defined. > > I expect people will want to use systrace on unarj when doing antivirus > scanning inside the ARJ archives with clamav. Unfortunately, the > current unarj port does not do any length checking on path/file names > during extraction so I'm trying to add checking. If the archive > contains brutally long path/file names, I expect it will get clobbered > by systrace. -any suggestions? Resarch to find out if increasing the stackgap is feasible has been stalled for a while. But I will pick it up again. I know it can be done on most archs, but e.g. vax has some more strict limits, so great care has to be taken. -Otto
