]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
setatt: Do not abort if no pattern is given.
authorAndre Noll <maan@tuebingen.mpg.de>
Sat, 29 Aug 2015 13:10:25 +0000 (15:10 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Sun, 30 Aug 2015 11:24:39 +0000 (13:24 +0200)
It is an error if no pattern is given to the setatt command.
For example,

setatt foo+ bar-

should result in a syntax error because no file name pattern is given.
The code in aft.c contains an assertion to detect this type of error,
but the afs proccess terminates if the condition of the assert
statement is not fulfilled:

para_server (afs): aft.c:2557: com_setatt_callback: Assertion `p < (char *)query->data + query->size' failed.

This patch turns the assertion into a normal check which merely causes
the command to fail if no pattern was given.

The bug was introduced two years ago in commit 73299ebf (com_setatt():
Allow to specify a file name pattern).

aft.c

diff --git a/aft.c b/aft.c
index 96f65e99fbf5b1bd2ae7eb863b864ce77e743c70..c4558f2040ac67e0a613177b786438a038f5bcc5 100644 (file)
--- a/aft.c
+++ b/aft.c
@@ -2561,7 +2561,8 @@ static void com_setatt_callback(int fd, const struct osl_object *query)
        if (!cad.add_mask && !cad.del_mask)
                goto out;
        pmd.patterns.data = p;
-       assert(p < (char *)query->data + query->size);
+       if (p >= (char *)query->data + query->size)
+               goto out;
        pmd.patterns.size = (char *)query->data + query->size - p;
        ret = for_each_matching_row(&pmd);
        if (ret < 0)