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

Diff for /mandoc/cgi.c between version 1.127 and 1.128

version 1.127, 2016/04/15 15:13:07 version 1.128, 2016/04/15 16:42:52
Line 21 
Line 21 
 #include <sys/time.h>  #include <sys/time.h>
   
 #include <ctype.h>  #include <ctype.h>
   #include <err.h>
 #include <errno.h>  #include <errno.h>
 #include <fcntl.h>  #include <fcntl.h>
 #include <limits.h>  #include <limits.h>
Line 564  pg_searchres(const struct req *req, struct manpage *r,
Line 565  pg_searchres(const struct req *req, struct manpage *r,
         for (i = 0; i < sz; i++) {          for (i = 0; i < sz; i++) {
                 if (validate_filename(r[i].file))                  if (validate_filename(r[i].file))
                         continue;                          continue;
                 fprintf(stderr, "invalid filename %s in %s database\n",                  warnx("invalid filename %s in %s database",
                     r[i].file, req->q.manpath);                      r[i].file, req->q.manpath);
                 pg_error_internal();                  pg_error_internal();
                 return;                  return;
Line 824  format(const struct req *req, const char *file)
Line 825  format(const struct req *req, const char *file)
   
         mparse_result(mp, &man, NULL);          mparse_result(mp, &man, NULL);
         if (man == NULL) {          if (man == NULL) {
                 fprintf(stderr, "fatal mandoc error: %s/%s\n",                  warnx("fatal mandoc error: %s/%s", req->q.manpath, file);
                     req->q.manpath, file);  
                 pg_error_internal();                  pg_error_internal();
                 mparse_free(mp);                  mparse_free(mp);
                 mchars_free();                  mchars_free();
Line 889  pg_show(struct req *req, const char *fullpath)
Line 889  pg_show(struct req *req, const char *fullpath)
          */           */
   
         if (chdir(manpath) == -1) {          if (chdir(manpath) == -1) {
                 fprintf(stderr, "chdir %s: %s\n",                  warn("chdir %s", manpath);
                     manpath, strerror(errno));  
                 pg_error_internal();                  pg_error_internal();
                 free(manpath);                  free(manpath);
                 return;                  return;
Line 931  pg_search(const struct req *req)
Line 930  pg_search(const struct req *req)
          * relative to the manpath root.           * relative to the manpath root.
          */           */
   
         if (-1 == (chdir(req->q.manpath))) {          if (chdir(req->q.manpath) == -1) {
                 fprintf(stderr, "chdir %s: %s\n",                  warn("chdir %s", req->q.manpath);
                     req->q.manpath, strerror(errno));  
                 pg_error_internal();                  pg_error_internal();
                 return;                  return;
         }          }
Line 1008  main(void)
Line 1006  main(void)
         itimer.it_interval.tv_sec = 2;          itimer.it_interval.tv_sec = 2;
         itimer.it_interval.tv_usec = 0;          itimer.it_interval.tv_usec = 0;
         if (setitimer(ITIMER_VIRTUAL, &itimer, NULL) == -1) {          if (setitimer(ITIMER_VIRTUAL, &itimer, NULL) == -1) {
                 fprintf(stderr, "setitimer: %s\n", strerror(errno));                  warn("setitimer");
                 pg_error_internal();                  pg_error_internal();
                 return EXIT_FAILURE;                  return EXIT_FAILURE;
         }          }
Line 1019  main(void)
Line 1017  main(void)
          * relative to the same position.           * relative to the same position.
          */           */
   
         if (-1 == chdir(MAN_DIR)) {          if (chdir(MAN_DIR) == -1) {
                 fprintf(stderr, "MAN_DIR: %s: %s\n",                  warn("MAN_DIR: %s", MAN_DIR);
                     MAN_DIR, strerror(errno));  
                 pg_error_internal();                  pg_error_internal();
                 return EXIT_FAILURE;                  return EXIT_FAILURE;
         }          }
Line 1142  pathgen(struct req *req)
Line 1139  pathgen(struct req *req)
         size_t   dpsz;          size_t   dpsz;
         ssize_t  len;          ssize_t  len;
   
         if (NULL == (fp = fopen("manpath.conf", "r"))) {          if ((fp = fopen("manpath.conf", "r")) == NULL) {
                 fprintf(stderr, "%s/manpath.conf: %s\n",                  warn("%s/manpath.conf", MAN_DIR);
                         MAN_DIR, strerror(errno));  
                 pg_error_internal();                  pg_error_internal();
                 exit(EXIT_FAILURE);                  exit(EXIT_FAILURE);
         }          }
Line 1158  pathgen(struct req *req)
Line 1154  pathgen(struct req *req)
                 req->p = mandoc_realloc(req->p,                  req->p = mandoc_realloc(req->p,
                     (req->psz + 1) * sizeof(char *));                      (req->psz + 1) * sizeof(char *));
                 if ( ! validate_urifrag(dp)) {                  if ( ! validate_urifrag(dp)) {
                         fprintf(stderr, "%s/manpath.conf contains "                          warnx("%s/manpath.conf contains "
                             "unsafe path \"%s\"\n", MAN_DIR, dp);                              "unsafe path \"%s\"", MAN_DIR, dp);
                         pg_error_internal();                          pg_error_internal();
                         exit(EXIT_FAILURE);                          exit(EXIT_FAILURE);
                 }                  }
                 if (NULL != strchr(dp, '/')) {                  if (strchr(dp, '/') != NULL) {
                         fprintf(stderr, "%s/manpath.conf contains "                          warnx("%s/manpath.conf contains "
                             "path with slash \"%s\"\n", MAN_DIR, dp);                              "path with slash \"%s\"", MAN_DIR, dp);
                         pg_error_internal();                          pg_error_internal();
                         exit(EXIT_FAILURE);                          exit(EXIT_FAILURE);
                 }                  }
Line 1175  pathgen(struct req *req)
Line 1171  pathgen(struct req *req)
         }          }
         free(dp);          free(dp);
   
         if ( req->p == NULL ) {          if (req->p == NULL) {
                 fprintf(stderr, "%s/manpath.conf is empty\n", MAN_DIR);                  warnx("%s/manpath.conf is empty", MAN_DIR);
                 pg_error_internal();                  pg_error_internal();
                 exit(EXIT_FAILURE);                  exit(EXIT_FAILURE);
         }          }

Legend:
Removed from v.1.127  
changed lines
  Added in v.1.128

CVSweb