[BACK]Return to cgi.c CVS log [TXT][DIR] Up to [cvsweb.bsd.lv] / mandoc

Diff for /mandoc/cgi.c between version 1.75 and 1.76

version 1.75, 2014/07/18 19:03:39 version 1.76, 2014/07/19 11:35:12
Line 466  resp_searchform(const struct req *req)
Line 466  resp_searchform(const struct req *req)
         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)
 {  {
Line 523  pg_searchres(const struct req *req, struct manpage *r,
Line 534  pg_searchres(const struct req *req, struct manpage *r,
         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
Line 777  format(const struct req *req, const char *file)
Line 797  format(const struct req *req, const char *file)
 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)
Line 807  pg_show(const struct req *req, const char *path)
Line 828  pg_show(const struct req *req, const char *path)
         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;
         }          }
   

Legend:
Removed from v.1.75  
changed lines
  Added in v.1.76

CVSweb