about summary refs log tree commit diff stats
path: root/src/teliva.c
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2022-03-20 17:58:14 -0700
committerKartik K. Agaram <vc@akkartik.com>2022-03-20 17:58:14 -0700
commit9ec94aa982692ba2c06bc7d89994459615ccd740 (patch)
tree1c6eb502974599a5ada6b60533db6aa1425022b2 /src/teliva.c
parentc7d3037e9db38a8391c2e3bc4c93eaaeaf7a6b46 (diff)
downloadteliva-9ec94aa982692ba2c06bc7d89994459615ccd740.tar.gz
disallow all relative paths (./ or ../)
Teliva's model doesn't include any way to change directory. We just have
relative paths and absolute paths. Relative paths should not be able to
reach into parent directories.

The current test is a bit hacky; it also disallows directories ending in
a period. Hopefully not an issue.
Diffstat (limited to 'src/teliva.c')
-rw-r--r--src/teliva.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/teliva.c b/src/teliva.c
index b88a42b..4ad530e 100644
--- a/src/teliva.c
+++ b/src/teliva.c
@@ -23,6 +23,10 @@ int starts_with(const char* s, const char* prefix) {
   return strncmp(s, prefix, strlen(prefix)) == 0;
 }
 
+int contains(const char* s, const char* sub) {
+  return strstr(s, sub) != NULL;
+}
+
 /*** Standard UI elements */
 
 int menu_column = 0;