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

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

version 1.76, 2014/07/19 11:35:12 version 1.77, 2014/07/19 13:15:11
Line 467  resp_searchform(const struct req *req)
Line 467  resp_searchform(const struct req *req)
 }  }
   
 static int  static int
   validate_manpath(const struct req *req, const char* manpath)
   {
           size_t   i;
   
           if ( ! strcmp(manpath, "mandoc"))
                   return(1);
   
           for (i = 0; i < req->psz; i++)
                   if ( ! strcmp(manpath, req->p[i]))
                           return(1);
   
           return(0);
   }
   
   static int
 validate_filename(const char *file)  validate_filename(const char *file)
 {  {
   
Line 819  pg_show(const struct req *req, const char *path)
Line 834  pg_show(const struct req *req, const char *path)
         }          }
         *sub++ = '\0';          *sub++ = '\0';
   
           if ( ! validate_manpath(req, path)) {
                   pg_error_badrequest(
                       "You specified an invalid manpath.");
                   return;
           }
   
         /*          /*
          * Begin by chdir()ing into the manpath.           * Begin by chdir()ing into the manpath.
          * This way we can pick up the database files, which are           * This way we can pick up the database files, which are
Line 826  pg_show(const struct req *req, const char *path)
Line 847  pg_show(const struct req *req, const char *path)
          */           */
   
         if (-1 == chdir(path)) {          if (-1 == chdir(path)) {
                 pg_error_badrequest(                  fprintf(stderr, "chdir %s: %s\n",
                     "You specified an invalid manpath.");                      path, strerror(errno));
                   pg_error_internal();
                 return;                  return;
         }          }
   
Line 861  pg_search(const struct req *req)
Line 883  pg_search(const struct req *req)
          */           */
   
         if (-1 == (chdir(req->q.manpath))) {          if (-1 == (chdir(req->q.manpath))) {
                 pg_error_badrequest(                  fprintf(stderr, "chdir %s: %s\n",
                     "You specified an invalid manpath.");                      req->q.manpath, strerror(errno));
                   pg_error_internal();
                 return;                  return;
         }          }
   
Line 953  main(void)
Line 976  main(void)
   
         if (NULL != (querystring = getenv("QUERY_STRING")))          if (NULL != (querystring = getenv("QUERY_STRING")))
                 http_parse(&req, querystring);                  http_parse(&req, querystring);
   
           if ( ! validate_manpath(&req, req.q.manpath)) {
                   pg_error_badrequest(
                       "You specified an invalid manpath.");
                   return(EXIT_FAILURE);
           }
   
         /* Dispatch to the three different pages. */          /* Dispatch to the three different pages. */
   

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

CVSweb