- strlcpy(file, ps->paths[vol], MAXPATHLEN);
- strlcat(file, "/", MAXPATHLEN);
- strlcat(file, (char *)val.data, MAXPATHLEN);
-
- (*db->close)(db);
-
- format(file);
+ if (NULL == (fn = memchr(cp, '\0', val.size)))
+ resp_baddb();
+ else if (++fn - cp >= (int)val.size)
+ resp_baddb();
+ else if (NULL == memchr(fn, '\0', val.size - (fn - cp)))
+ resp_baddb();
+ else {
+ strlcpy(file, ps->paths[vol], MAXPATHLEN);
+ strlcat(file, "/", MAXPATHLEN);
+ strlcat(file, fn, MAXPATHLEN);
+ if (0 == strcmp(cp, "cat"))
+ catman(file);
+ else
+ format(file);
+ }
+out:
+ (*idx->close)(idx);