From 5f6b5fd93048298b83020f19d6ab2edc67104f87 Mon Sep 17 00:00:00 2001 From: Vreixo Formoso Date: Wed, 26 Dec 2007 16:34:07 +0100 Subject: [PATCH] Guard against wrong POSIX filenames in node. --- src/node.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/node.c b/src/node.c index bd4bbdf..4a3355b 100644 --- a/src/node.c +++ b/src/node.c @@ -80,10 +80,21 @@ int iso_node_set_name(IsoNode *node, const char *name) { char *new; - /* guard against the empty string */ + /* guard against the empty string or big names... */ if (name[0] == '\0' || strlen(name) > 255) { return ISO_WRONG_ARG_VALUE; } + + /* ...against "." and ".." names... */ + if (!strcmp(name, ".") || !strcmp(name, "..")) { + return ISO_WRONG_ARG_VALUE; + } + + /* ...and against names with '/' */ + if (strchr(name, '/') != NULL) { + return ISO_WRONG_ARG_VALUE; + } + if ((IsoNode*)node->parent == node) { /* you can't change name of the root node */ return ISO_WRONG_ARG_VALUE;