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

Diff for /src/usr.bin/mandoc/mandocdb.c between version 1.43 and 1.44

version 1.43, 2013/05/29 23:15:11 version 1.44, 2013/06/05 02:02:53
Line 15 
Line 15 
  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF   * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.   * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */   */
 #include <sys/param.h>  
 #include <sys/types.h>  #include <sys/types.h>
   
 #include <assert.h>  #include <assert.h>
Line 24 
Line 23 
 #include <errno.h>  #include <errno.h>
 #include <fcntl.h>  #include <fcntl.h>
 #include <getopt.h>  #include <getopt.h>
   #include <limits.h>
 #include <stdio.h>  #include <stdio.h>
 #include <stdint.h>  #include <stdint.h>
 #include <stdlib.h>  #include <stdlib.h>
Line 46 
Line 46 
 /* Access to the mandoc database on disk. */  /* Access to the mandoc database on disk. */
   
 struct  mdb {  struct  mdb {
         char              idxn[MAXPATHLEN]; /* index db filename */          char              idxn[PATH_MAX]; /* index db filename */
         char              dbn[MAXPATHLEN]; /* keyword db filename */          char              dbn[PATH_MAX]; /* keyword db filename */
         DB               *idx; /* index recno database */          DB               *idx; /* index recno database */
         DB               *db; /* keyword btree database */          DB               *db; /* keyword btree database */
 };  };
Line 402 
Line 402 
                         exit((int)MANDOCLEVEL_BADARG);                          exit((int)MANDOCLEVEL_BADARG);
                 }                  }
   
                 strlcat(mdb.dbn, pbuf, MAXPATHLEN);                  strlcat(mdb.dbn, pbuf, PATH_MAX);
                 sz1 = strlcat(mdb.dbn, MANDOC_DB, MAXPATHLEN);                  sz1 = strlcat(mdb.dbn, MANDOC_DB, PATH_MAX);
   
                 strlcat(mdb.idxn, pbuf, MAXPATHLEN);                  strlcat(mdb.idxn, pbuf, PATH_MAX);
                 sz2 = strlcat(mdb.idxn, MANDOC_IDX, MAXPATHLEN);                  sz2 = strlcat(mdb.idxn, MANDOC_IDX, PATH_MAX);
   
                 if (sz1 >= MAXPATHLEN || sz2 >= MAXPATHLEN) {                  if (sz1 >= PATH_MAX || sz2 >= PATH_MAX) {
                         fprintf(stderr, "%s: path too long\n", mdb.idxn);                          fprintf(stderr, "%s: path too long\n", mdb.idxn);
                         exit((int)MANDOCLEVEL_BADARG);                          exit((int)MANDOCLEVEL_BADARG);
                 }                  }
Line 486 
Line 486 
   
                 flags = O_CREAT | O_EXCL | O_RDWR;                  flags = O_CREAT | O_EXCL | O_RDWR;
                 while (NULL == mdb.db) {                  while (NULL == mdb.db) {
                         strlcpy(mdb.dbn, MANDOC_DB, MAXPATHLEN);                          strlcpy(mdb.dbn, MANDOC_DB, PATH_MAX);
                         strlcat(mdb.dbn, ".XXXXXXXXXX", MAXPATHLEN);                          strlcat(mdb.dbn, ".XXXXXXXXXX", PATH_MAX);
                         if (NULL == mktemp(mdb.dbn)) {                          if (NULL == mktemp(mdb.dbn)) {
                                 perror(mdb.dbn);                                  perror(mdb.dbn);
                                 exit((int)MANDOCLEVEL_SYSERR);                                  exit((int)MANDOCLEVEL_SYSERR);
Line 500 
Line 500 
                         }                          }
                 }                  }
                 while (NULL == mdb.idx) {                  while (NULL == mdb.idx) {
                         strlcpy(mdb.idxn, MANDOC_IDX, MAXPATHLEN);                          strlcpy(mdb.idxn, MANDOC_IDX, PATH_MAX);
                         strlcat(mdb.idxn, ".XXXXXXXXXX", MAXPATHLEN);                          strlcat(mdb.idxn, ".XXXXXXXXXX", PATH_MAX);
                         if (NULL == mktemp(mdb.idxn)) {                          if (NULL == mktemp(mdb.idxn)) {
                                 perror(mdb.idxn);                                  perror(mdb.idxn);
                                 unlink(mdb.dbn);                                  unlink(mdb.dbn);
Line 1634 
Line 1634 
 ofile_argbuild(int argc, char *argv[], struct of **of,  ofile_argbuild(int argc, char *argv[], struct of **of,
                 const char *basedir)                  const char *basedir)
 {  {
         char             buf[MAXPATHLEN];          char             buf[PATH_MAX];
         char             pbuf[PATH_MAX];          char             pbuf[PATH_MAX];
         const char      *sec, *arch, *title;          const char      *sec, *arch, *title;
         char            *relpath, *p;          char            *relpath, *p;
Line 1744 
Line 1744 
 ofile_dirbuild(const char *dir, const char* psec, const char *parch,  ofile_dirbuild(const char *dir, const char* psec, const char *parch,
                 int p_src_form, struct of **of)                  int p_src_form, struct of **of)
 {  {
         char             buf[MAXPATHLEN];          char             buf[PATH_MAX];
         size_t           sz;          size_t           sz;
         DIR             *d;          DIR             *d;
         const char      *fn, *sec, *arch;          const char      *fn, *sec, *arch;
Line 1810 
Line 1810 
                         }                          }
   
                         buf[0] = '\0';                          buf[0] = '\0';
                         strlcat(buf, dir, MAXPATHLEN);                          strlcat(buf, dir, PATH_MAX);
                         strlcat(buf, "/", MAXPATHLEN);                          strlcat(buf, "/", PATH_MAX);
                         sz = strlcat(buf, fn, MAXPATHLEN);                          sz = strlcat(buf, fn, PATH_MAX);
   
                         if (MAXPATHLEN <= sz) {                          if (PATH_MAX <= sz) {
                                 if (warnings) fprintf(stderr, "%s/%s: "                                  if (warnings) fprintf(stderr, "%s/%s: "
                                     "path too long\n", dir, fn);                                      "path too long\n", dir, fn);
                                 continue;                                  continue;
Line 1885 
Line 1885 
                 if (0 == use_all && MANDOC_FORM & src_form &&                  if (0 == use_all && MANDOC_FORM & src_form &&
                                 '\0' != *psec) {                                  '\0' != *psec) {
                         buf[0] = '\0';                          buf[0] = '\0';
                         strlcat(buf, dir, MAXPATHLEN);                          strlcat(buf, dir, PATH_MAX);
                         p = strrchr(buf, '/');                          p = strrchr(buf, '/');
                         if ('\0' != *parch && NULL != p)                          if ('\0' != *parch && NULL != p)
                                 for (p--; p > buf; p--)                                  for (p--; p > buf; p--)
Line 1897 
Line 1897 
                                 p++;                                  p++;
                         if (0 == strncmp("cat", p, 3))                          if (0 == strncmp("cat", p, 3))
                                 memcpy(p, "man", 3);                                  memcpy(p, "man", 3);
                         strlcat(buf, "/", MAXPATHLEN);                          strlcat(buf, "/", PATH_MAX);
                         sz = strlcat(buf, fn, MAXPATHLEN);                          sz = strlcat(buf, fn, PATH_MAX);
                         if (sz >= MAXPATHLEN) {                          if (sz >= PATH_MAX) {
                                 if (warnings) fprintf(stderr,                                  if (warnings) fprintf(stderr,
                                     "%s/%s: path too long\n",                                      "%s/%s: path too long\n",
                                     dir, fn);                                      dir, fn);
Line 1908 
Line 1908 
                         q = strrchr(buf, '.');                          q = strrchr(buf, '.');
                         if (NULL != q && p < q++) {                          if (NULL != q && p < q++) {
                                 *q = '\0';                                  *q = '\0';
                                 sz = strlcat(buf, psec, MAXPATHLEN);                                  sz = strlcat(buf, psec, PATH_MAX);
                                 if (sz >= MAXPATHLEN) {                                  if (sz >= PATH_MAX) {
                                         if (warnings) fprintf(stderr,                                          if (warnings) fprintf(stderr,
                                             "%s/%s: path too long\n",                                              "%s/%s: path too long\n",
                                             dir, fn);                                              dir, fn);
Line 1923 
Line 1923 
                 buf[0] = '\0';                  buf[0] = '\0';
                 assert('.' == dir[0]);                  assert('.' == dir[0]);
                 if ('/' == dir[1]) {                  if ('/' == dir[1]) {
                         strlcat(buf, dir + 2, MAXPATHLEN);                          strlcat(buf, dir + 2, PATH_MAX);
                         strlcat(buf, "/", MAXPATHLEN);                          strlcat(buf, "/", PATH_MAX);
                 }                  }
                 sz = strlcat(buf, fn, MAXPATHLEN);                  sz = strlcat(buf, fn, PATH_MAX);
                 if (sz >= MAXPATHLEN) {                  if (sz >= PATH_MAX) {
                         if (warnings) fprintf(stderr,                          if (warnings) fprintf(stderr,
                             "%s/%s: path too long\n", dir, fn);                              "%s/%s: path too long\n", dir, fn);
                         continue;                          continue;

Legend:
Removed from v.1.43  
changed lines
  Added in v.1.44