aboutsummaryrefslogtreecommitdiffstats
path: root/safepath.h
Commit message (Collapse)AuthorAgeFilesLines
* Use regular expression against /proc symlinks.Kaz Kylheku2022-07-291-0/+2
| | | | | | | | | | | | | | | | * safepath.c (bad_proc): New static variable; regular expression that matches paths under /proc that traverse dangerous symlinks. (bad_proc_rx): Compiled version of above regex. (abs_path_check): Replace ad-hoc path match with regexec call. (safepath_init, safepath_deinit): New functions needed because have to compile a regular expression one time, and then keep using it. We could do this lazily but then we need pthread_once to make things thread safe. * safepath.h (safepath_init, safepath_cleanup): Declared. * testsp.c (main): Call safepath_init and safepath_cleanup.
* Correctly handle readlink overflow.Kaz Kylheku2022-07-241-0/+1
| | | | | | | | | | * safepath.h (SAFEPATH_TOOLONG): New enum constant. * safepath.c (safepatch_check): Don't ignore the truncation situation from readlink. Use the full buffer length, and if readlink returns 256, then diagnose overflow using the new SAFEPATH_TOOLONG error code and bail. (safepath_strerr): Map SAFEPATH_TOOLONG.
* Add SAFEPATH_NOTIDIR error code.Kaz Kylheku2022-07-241-0/+1
| | | | | | | | * safepath.h (SAFEPATH_NOTDIR): New enum. * safepath.c (safepath_err, set_errno): Handle conversion between SAFEPATH_NOTDIR and ENOTDIR. (safepath_strerr): Map SAFEPATH_NOTDIR to message.
* Map safepath errors to strings.Kaz Kylheku2022-07-231-0/+1
| | | | | | | * safepath.[ch]: New function, safepath_strerr. * testsp.c (main): Use new function to print message, rather than integer code.
* safepath: new project.Kaz Kylheku2022-07-221-0/+59