aboutsummaryrefslogtreecommitdiffstats
path: root/safepath.h
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2022-07-24 16:14:09 -0700
committerKaz Kylheku <kaz@kylheku.com>2022-07-24 16:14:09 -0700
commit645b1184ec996696f24a65c1ad39fc50a1e5cbb2 (patch)
tree49b7a45ba5a9ec447d97e344a19c0a393bb64cd6 /safepath.h
parent527c20f525c0f178707dea37589f494c9f45e48f (diff)
downloadsafepath-645b1184ec996696f24a65c1ad39fc50a1e5cbb2.tar.gz
safepath-645b1184ec996696f24a65c1ad39fc50a1e5cbb2.tar.bz2
safepath-645b1184ec996696f24a65c1ad39fc50a1e5cbb2.zip
Correctly handle readlink overflow.
* 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.
Diffstat (limited to 'safepath.h')
-rw-r--r--safepath.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/safepath.h b/safepath.h
index 766a163..99786b1 100644
--- a/safepath.h
+++ b/safepath.h
@@ -45,6 +45,7 @@ enum {
SAFEPATH_INVAL, /* path is invalid */
SAFEPATH_NOMEM, /* out of memory */
SAFEPATH_LOOP, /* more than 8 levels of symlink */
+ SAFEPATH_TOOLONG, /* component or symlink target too long */
};
int safepath_check(const char *name);