[BACK]Return to cgi.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / mandoc

Diff for /src/usr.bin/mandoc/cgi.c between version 1.15 and 1.16

version 1.15, 2014/07/18 19:02:07 version 1.16, 2014/07/19 11:35:09
Line 462 
Line 462 
         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 519 
Line 530 
         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 773 
Line 793 
 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 803 
Line 824 
         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.15  
changed lines
  Added in v.1.16