version 1.15, 2014/07/18 19:02:07 |
version 1.16, 2014/07/19 11:35:09 |
|
|
puts("<!-- End search form. //-->"); |
puts("<!-- End search form. //-->"); |
} |
} |
|
|
|
static int |
|
validate_filename(const char *file) |
|
{ |
|
|
|
if ('.' == file[0] && '/' == file[1]) |
|
file += 2; |
|
|
|
return ( ! (strstr(file, "../") || strstr(file, "/..") || |
|
(strncmp(file, "man", 3) && strncmp(file, "cat", 3)))); |
|
} |
|
|
static void |
static void |
pg_index(const struct req *req) |
pg_index(const struct req *req) |
{ |
{ |
|
|
int prio, priouse; |
int prio, priouse; |
char sec; |
char sec; |
|
|
|
for (i = 0; i < sz; i++) { |
|
if (validate_filename(r[i].file)) |
|
continue; |
|
fprintf(stderr, "invalid filename %s in %s database\n", |
|
r[i].file, req->q.manpath); |
|
pg_error_internal(); |
|
return; |
|
} |
|
|
if (1 == sz) { |
if (1 == sz) { |
/* |
/* |
* If we have just one result, then jump there now |
* If we have just one result, then jump there now |
|
|
static void |
static void |
resp_show(const struct req *req, const char *file) |
resp_show(const struct req *req, const char *file) |
{ |
{ |
if ('.' == file[0] || '/' == file[1]) |
|
|
if ('.' == file[0] && '/' == file[1]) |
file += 2; |
file += 2; |
|
|
if ('c' == *file) |
if ('c' == *file) |
|
|
if (-1 == chdir(path)) { |
if (-1 == chdir(path)) { |
pg_error_badrequest( |
pg_error_badrequest( |
"You specified an invalid manpath."); |
"You specified an invalid manpath."); |
|
return; |
|
} |
|
|
|
if ( ! validate_filename(sub)) { |
|
pg_error_badrequest( |
|
"You specified an invalid manual file."); |
return; |
return; |
} |
} |
|
|