Advertisement
frakswe

rdrview openbsd diff

Oct 18th, 2020
2,609
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 2.90 KB | None | 0 0
  1. --- Makefile    Mon Oct 19 03:57:21 2020
  2. +++ Makefile    Mon Oct 19 03:38:46 2020
  3. @@ -1,9 +1,9 @@
  4. -CC = gcc
  5. +CC = cc
  6.  
  7.  CFLAGS = -DNDEBUG -O2 -Wall -Wextra -fno-strict-aliasing
  8.  override CFLAGS += $(shell curl-config --cflags) $(shell xml2-config --cflags)
  9.  
  10. -LDLIBS = $(shell curl-config --libs) $(shell xml2-config --libs) -lm -lseccomp
  11. +LDLIBS = $(shell curl-config --libs) $(shell xml2-config --libs) -lm
  12.  
  13.  BINDIR = /usr/bin
  14.  MANDIR = /usr/share/man/man1
  15.  
  16. --- rdrview.c   Mon Oct 19 03:57:21 2020
  17. +++ rdrview.c   Mon Oct 19 03:47:15 2020
  18. @@ -30,7 +30,9 @@
  19.  #include <string.h>
  20.  #include <getopt.h>
  21.  #include <signal.h>
  22. +#ifndef __OpenBSD__
  23.  #include <seccomp.h>
  24. +#endif
  25.  #include <sys/types.h>
  26.  #include <sys/wait.h>
  27.  #include <sys/stat.h>
  28. @@ -164,7 +166,7 @@
  29.     /* Just ignore failures, we can guess the encoding or get it elsewhere */
  30.     if (curl_easy_getinfo(curl, CURLINFO_CONTENT_TYPE, &type) || !type)
  31.         return;
  32. -   charset = strcasestr(type, "charset="); /* TODO: whitespace? */
  33. +   charset = Mystrcasestr(type, "charset="); /* TODO: whitespace? */
  34.     if (!charset)
  35.         return;
  36.  
  37. @@ -272,7 +274,7 @@
  38.  /**
  39.   * Wrapper around xmlStrcasestr() that takes chars and doesn't return constants
  40.   */
  41. -static inline char *strcasestr(const char *haystack, const char *needle)
  42. +static inline char *Mystrcasestr(const char *haystack, const char *needle)
  43.  {
  44.     return (char *)xmlStrcasestr((xmlChar *)haystack, (xmlChar *)needle);
  45.  }
  46. @@ -293,7 +295,7 @@
  47.     lastchar = map[size - 1];
  48.     map[size - 1] = '\0';
  49.  
  50. -   opentag = strcasestr(map, "<script");
  51. +   opentag = Mystrcasestr(map, "<script");
  52.     while (opentag) {
  53.         char *gt, *closetag;
  54.  
  55. @@ -301,14 +303,14 @@
  56.         if (!gt)
  57.             break; /* Malformed html, just ignore it for now and move on */
  58.         if (*(gt - 1) == '/') { /* No closing tag for this node */
  59. -           opentag = strcasestr(gt, "<script");
  60. +           opentag = Mystrcasestr(gt, "<script");
  61.             continue;
  62.         }
  63. -       closetag = strcasestr(gt, "</script>");
  64. +       closetag = Mystrcasestr(gt, "</script>");
  65.         if (!closetag)
  66.             break; /* Malformed html, just ignore it for now and move on */
  67.         memset(gt + 1, 'X', closetag - (gt + 1));
  68. -       opentag = strcasestr(closetag, "<script");
  69. +       opentag = Mystrcasestr(closetag, "<script");
  70.     }
  71.  
  72.     map[size - 1] = lastchar;
  73. @@ -692,6 +694,7 @@
  74.     sigaction(SIGTERM, &act, NULL);
  75.  }
  76.  
  77. +#ifndef __OpenBSD__
  78.  /**
  79.   * Restrict the process to working with its existing temporary files
  80.   */
  81. @@ -746,6 +749,7 @@
  82.     }
  83.  }
  84.  #endif /* NDEBUG */
  85. +#endif /* __OpenBSD__ */
  86.  
  87.  /* Descriptors for the encodings supported via iconv; for now only GB2312 */
  88.  static iconv_t gb2312_cd;
  89. @@ -786,9 +790,11 @@
  90.         stdin_to_file(input_fp);
  91.  
  92.     /* TODO: consider ways to sandbox the libcurl stuff as well */
  93. -   start_sandbox();
  94. -   assert_sandbox_works();
  95.  
  96. +#ifndef __OpenBSD__
  97. +        start_sandbox();
  98. +   assert_sandbox_works();
  99. +#endif
  100.     doc = parse_file(input_fp);
  101.     init_regexes();
  102.  
  103.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement