media/mtransport/third_party/nrappkit/upstream.diff

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     1 diff --git a/media/mtransport/third_party/nrappkit/src/event/async_wait.h b/media/mtransport/third_party/nrappkit/src/event/async_wait.h
     2 --- a/media/mtransport/third_party/nrappkit/src/event/async_wait.h
     3 +++ b/media/mtransport/third_party/nrappkit/src/event/async_wait.h
     4 @@ -38,21 +38,21 @@
     7  #ifndef _async_wait_h
     8  #define _async_wait_h
    10  #ifdef HAVE_SYS_TIME_H
    11  #include <sys/time.h>
    12  #endif
    13  #include <csi_platform.h>
    15 -typedef void (*NR_async_cb)(int resource,int how,void *arg);
    16 +typedef void (*NR_async_cb)(NR_SOCKET resource,int how,void *arg);
    18  #define NR_ASYNC_WAIT_READ 0
    19  #define NR_ASYNC_WAIT_WRITE 1
    22  int NR_async_wait_init(void);
    23  int NR_async_wait(NR_SOCKET sock, int how, NR_async_cb cb,void *cb_arg,
    24                              char *function,int line);
    25  int NR_async_cancel(NR_SOCKET sock,int how);
    26  int NR_async_schedule(NR_async_cb cb,void *arg,char *function,int line);
    27 diff --git a/media/mtransport/third_party/nrappkit/src/log/r_log.c b/media/mtransport/third_party/nrappkit/src/log/r_log.c
    28 --- a/media/mtransport/third_party/nrappkit/src/log/r_log.c
    29 +++ b/media/mtransport/third_party/nrappkit/src/log/r_log.c
    30 @@ -33,28 +33,41 @@
    31     POSSIBILITY OF SUCH DAMAGE.
    34     ekr@rtfm.com  Mon Dec  3 15:24:38 2001
    35   */
    38  static char *RCSSTRING __UNUSED__ ="$Id: r_log.c,v 1.10 2008/11/25 22:25:18 adamcain Exp $";
    41 +#ifdef LINUX
    42 +#define _BSD_SOURCE
    43 +#endif
    44 +
    45  #include "r_log.h"
    46  #include "hex.h"
    47 +
    48  #include <string.h>
    49 +#include <errno.h>
    50 +#ifndef _MSC_VER
    51 +#include <strings.h>
    52 +#include <syslog.h>
    53 +#endif
    54  #include <registry.h>
    55  #include <time.h>
    56 +
    57 +
    58  #include "nr_common.h"
    59  #include "nr_reg_keys.h"
    61 +
    62  #define LOGGING_DEFAULT_LEVEL  5
    64  int NR_LOG_LOGGING = 0;
    66  static char *log_level_strings[]={
    67       "EMERG",
    68       "ALERT",
    69       "CRIT",
    70       "ERR",
    71       "WARNING",
    72 diff --git a/media/mtransport/third_party/nrappkit/src/port/darwin/include/csi_platform.h b/media/mtransport/third_party/nrappkit/src/port/darwin/include/csi_platform.h
    73 --- a/media/mtransport/third_party/nrappkit/src/port/darwin/include/csi_platform.h
    74 +++ b/media/mtransport/third_party/nrappkit/src/port/darwin/include/csi_platform.h
    75 @@ -37,17 +37,21 @@
    76   */
    79  #ifndef _platform_h
    80  #define _platform_h
    82  #include <unistd.h>
    84  #define STDIO_BYTES_BUFFERED(fp) (fp->_r)
    86 +#ifdef NR_SOCKET_IS_VOID_PTR
    87 +typedef void* NR_SOCKET;
    88 +#else
    89  typedef int NR_SOCKET;
    90  #define NR_SOCKET_READ(sock,buf,count)   read((sock),(buf),(count))
    91  #define NR_SOCKET_WRITE(sock,buf,count)  write((sock),(buf),(count))
    92  #define NR_SOCKET_CLOSE(sock)            close(sock)
    93 +#endif
    95  #endif
    97 diff --git a/media/mtransport/third_party/nrappkit/src/port/linux/include/csi_platform.h b/media/mtransport/third_party/nrappkit/src/port/linux/include/csi_platform.h
    98 --- a/media/mtransport/third_party/nrappkit/src/port/linux/include/csi_platform.h
    99 +++ b/media/mtransport/third_party/nrappkit/src/port/linux/include/csi_platform.h
   100 @@ -35,17 +35,21 @@
   102     ekr@rtfm.com  Mon Dec 13 17:26:51 2004
   103   */
   106  #ifndef _platform_h
   107  #define _platform_h
   109  #include <linux_funcs.h>
   111 +#ifdef NR_SOCKET_IS_VOID_PTR
   112 +typedef void* NR_SOCKET;
   113 +#else
   114  typedef int NR_SOCKET;
   115  #define NR_SOCKET_READ(sock,buf,count)   read((sock),(buf),(count))
   116  #define NR_SOCKET_WRITE(sock,buf,count)  write((sock),(buf),(count))
   117  #define NR_SOCKET_CLOSE(sock)            close(sock)
   118 +#endif
   120  #endif
   122 diff --git a/media/mtransport/third_party/nrappkit/src/port/win32/include/csi_platform.h b/media/mtransport/third_party/nrappkit/src/port/win32/include/csi_platform.h
   123 --- a/media/mtransport/third_party/nrappkit/src/port/win32/include/csi_platform.h
   124 +++ b/media/mtransport/third_party/nrappkit/src/port/win32/include/csi_platform.h
   125 @@ -44,45 +44,51 @@
   126  #define _WIN32_WINNT 0x0400  // This prevents weird "'TryEnterCriticalSection': identifier not found"
   127                               // compiler errors when poco/win32_mutex.h is included
   128  #endif
   130  #define UINT8 UBLAH_IGNORE_ME_PLEASE
   131  #define INT8 BLAH_IGNORE_ME_PLEASE
   132  #include <winsock2.h>
   133  #undef UINT8
   134  #undef INT8
   135  #include <r_types.h>
   136 +#include <errno.h>
   138  #define strcasecmp _stricmp
   139  #define strncasecmp _strnicmp
   140 -#define snprintf _snprintf
   142  #define strcasestr stristr
   144  /* Hack version of strlcpy (in util/util.c) */
   145  size_t strlcat(char *dst, const char *src, size_t siz);
   147  /* Hack version of getopt() (in util/getopt.c) */
   148  int getopt(int argc, char *argv[], char *opstring);
   149  extern char *optarg;
   150  extern int optind;
   151  extern int opterr;
   153  /* Hack version of gettimeofday() (in util/util.c) */
   154  int gettimeofday(struct timeval *tv, void *tz);
   156 +#ifdef NR_SOCKET_IS_VOID_PTR
   157 +typedef void* NR_SOCKET;
   158 +#else
   159  typedef SOCKET NR_SOCKET;
   160  #define NR_SOCKET_READ(sock,buf,count)   recv((sock),(buf),(count),0)
   161  #define NR_SOCKET_WRITE(sock,buf,count)  send((sock),(buf),(count),0)
   162  #define NR_SOCKET_CLOSE(sock)            closesocket(sock)
   163 +#endif
   165 +#ifndef EHOSTUNREACH
   166  #define EHOSTUNREACH    WSAEHOSTUNREACH
   167 +#endif
   169  #define LOG_EMERG       0
   170  #define LOG_ALERT       1
   171  #define LOG_CRIT        2
   172  #define LOG_ERR         3
   173  #define LOG_WARNING     4
   174  #define LOG_NOTICE      5
   175  #define LOG_INFO        6
   176  #define LOG_DEBUG       7
   178 diff --git a/media/mtransport/third_party/nrappkit/src/registry/registry.c b/media/mtransport/third_party/nrappkit/src/registry/registry.c
   179 --- a/media/mtransport/third_party/nrappkit/src/registry/registry.c
   180 +++ b/media/mtransport/third_party/nrappkit/src/registry/registry.c
   181 @@ -37,21 +37,22 @@
   182   *    INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
   183   *    CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   184   *    ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   185   *    POSSIBILITY OF SUCH DAMAGE.
   186   *
   187   *
   188   */
   190  #include <assert.h>
   191  #include <string.h>
   192 -#ifndef WIN32
   193 +#ifndef _MSC_VER
   194 +#include <strings.h>
   195  #include <sys/param.h>
   196  #include <netinet/in.h>
   197  #endif
   198  #ifdef OPENSSL
   199  #include <openssl/ssl.h>
   200  #endif
   201  #include <ctype.h>
   202  #include "registry.h"
   203  #include "registry_int.h"
   204  #include "registry_vtbl.h"
   205 diff --git a/media/mtransport/third_party/nrappkit/src/util/libekr/r_crc32.c b/media/mtransport/third_party/nrappkit/src/util/libekr/r_crc32.c
   206 --- a/media/mtransport/third_party/nrappkit/src/util/libekr/r_crc32.c
   207 +++ b/media/mtransport/third_party/nrappkit/src/util/libekr/r_crc32.c
   208 @@ -58,20 +58,21 @@
   209   * the crc computation is finished.  The crc should be complemented
   210   * before transmission.
   211   * The variable corresponding to the macro argument "crc" should
   212   * be an unsigned long and should be preset to all ones for Ethernet
   213   * use.  An error-free packet will leave 0xDEBB20E3 in the crc.
   214   *			Spencer Garrett <srg@quick.com>
   215   */
   218  #include <sys/types.h>
   219 +#include <r_types.h>
   221  static char *RCSSTRING __UNUSED__ ="$Id: r_crc32.c,v 1.4 2008/11/26 03:22:02 adamcain Exp $";
   223  #ifdef WIN32
   224  #define u_int32_t  UINT4
   225  #endif
   227  #define CRC(crc, ch)	 (crc = (crc >> 8) ^ crctab[(crc ^ (ch)) & 0xff])
   229  /* generated using the AUTODIN II polynomial
   230 diff --git a/media/mtransport/third_party/nrappkit/src/util/libekr/r_macros.h b/media/mtransport/third_party/nrappkit/src/util/libekr/r_macros.h
   231 --- a/media/mtransport/third_party/nrappkit/src/util/libekr/r_macros.h
   232 +++ b/media/mtransport/third_party/nrappkit/src/util/libekr/r_macros.h
   233 @@ -118,20 +118,20 @@
   234  #ifndef MIN
   235  #define MIN(a,b) ((a)>(b))?(b):(a)
   236  #endif
   238  #ifndef MAX
   239  #define MAX(a,b) ((b)>(a))?(b):(a)
   240  #endif
   242  #ifdef DEBUG
   243  #define DBG(a) debug a
   244 -int debug(int class,char *format,...);
   245 +int debug(int cls, char *format,...);
   246  #else
   247  #define DBG(a)
   248  #endif
   250  #define UNIMPLEMENTED do { fprintf(stderr,"%s:%d Function %s unimplemented\n",__FILE__,__LINE__,__FUNCTION__); abort(); } while(0)
   252  #include "r_memory.h"
   254  #endif
   255 diff --git a/media/mtransport/third_party/nrappkit/src/util/libekr/r_time.h b/media/mtransport/third_party/nrappkit/src/util/libekr/r_time.h
   256 --- a/media/mtransport/third_party/nrappkit/src/util/libekr/r_time.h
   257 +++ b/media/mtransport/third_party/nrappkit/src/util/libekr/r_time.h
   258 @@ -77,35 +77,25 @@
   259     $Id: r_time.h,v 1.4 2007/06/26 22:37:57 adamcain Exp $
   262     ekr@rtfm.com  Thu Mar  4 08:45:41 1999
   263   */
   266  #ifndef _r_time_h
   267  #define _r_time_h
   269 +#include <csi_platform.h>
   271 -#ifdef WIN32
   272 -#  include <time.h>
   273 -#else
   274 -/* Cribbed from the autoconf doc */
   275 -# if TIME_WITH_SYS_TIME
   276 -#  include <sys/time.h>
   277 -#  include <time.h>
   278 -# else
   279 -#  if HAVE_SYS_TIME_H
   280 -#   include <sys/time.h>
   281 -#  else
   282 -#   include <time.h>
   283 -#  endif
   284 -# endif
   285 +#ifndef WIN32
   286 +#include <sys/time.h>
   287 +#include <time.h>
   288  #endif
   290  int r_timeval_diff(struct timeval *t1,struct timeval *t0, struct timeval *diff);
   291  int r_timeval_add(struct timeval *t1,struct timeval *t2, struct timeval *sum);
   292  int r_timeval_cmp(struct timeval *t1,struct timeval *t2);
   294  UINT8 r_timeval2int(struct timeval *tv);
   295  int r_int2timeval(UINT8 t,struct timeval *tv);
   296  UINT8 r_gettimeint(void);
   298 diff --git a/media/mtransport/third_party/nrappkit/src/util/util.c b/media/mtransport/third_party/nrappkit/src/util/util.c
   299 --- a/media/mtransport/third_party/nrappkit/src/util/util.c
   300 +++ b/media/mtransport/third_party/nrappkit/src/util/util.c
   301 @@ -292,20 +292,22 @@ int nr_sha1_file(char *filename,UCHAR *o
   303      return(_status);
   304    }
   306  #endif
   308  #ifdef WIN32
   309    // TODO
   310  #else
   312 +#if 0
   313 +
   314  #include <fts.h>
   316  int nr_rm_tree(char *path)
   317    {
   318      FTS *fts=0;
   319      FTSENT *p;
   320      int failed=0;
   321      int _status;
   322      char *argv[2];
   324 @@ -337,20 +339,21 @@ int nr_rm_tree(char *path)
   325      }
   327      if(failed)
   328        ABORT(R_FAILED);
   330      _status=0;
   331    abort:
   332      if(fts) fts_close(fts);
   333      return(_status);
   334    }
   335 +#endif
   337  int nr_write_pid_file(char *pid_filename)
   338    {
   339      FILE *fp;
   340      int _status;
   342      if(!pid_filename)
   343        ABORT(R_BAD_ARGS);
   345      unlink(pid_filename);
   346 @@ -739,12 +742,24 @@ int gettimeofday(struct timeval *tv, voi
   347       * since the Epoch */
   348      SystemTimeToFileTime(&st, &ft);
   349      u.HighPart = ft.dwHighDateTime;
   350      u.LowPart = ft.dwLowDateTime;
   352      tv->tv_sec = (long) (u.QuadPart / 10000000L);
   353      tv->tv_usec = (long) (st.wMilliseconds * 1000);;
   355      return 0;
   356    }
   357 +
   358 +int snprintf(char *buffer, size_t n, const char *format, ...)
   359 +{
   360 +  va_list argp;
   361 +  int ret;
   362 +  va_start(argp, format);
   363 +  ret = _vscprintf(format, argp);
   364 +  vsnprintf_s(buffer, n, _TRUNCATE, format, argp);
   365 +  va_end(argp);
   366 +  return ret;
   367 +}
   368 +
   369  #endif
   371 diff --git a/media/mtransport/third_party/nrappkit/src/util/util.h b/media/mtransport/third_party/nrappkit/src/util/util.h
   372 --- a/media/mtransport/third_party/nrappkit/src/util/util.h
   373 +++ b/media/mtransport/third_party/nrappkit/src/util/util.h
   374 @@ -57,12 +57,17 @@ int nr_drop_privileges(char *username);
   375  int nr_hex_ascii_dump(Data *data);
   376  int nr_fwrite_all(FILE *fp,UCHAR *buf,int len);
   377  int nr_sha1_file(char *filename,UCHAR *out);
   378  int nr_bin2hex(UCHAR *in,int len,UCHAR *out);
   379  int nr_rm_tree(char *path);
   380  int nr_write_pid_file(char *pid_filename);
   382  int nr_reg_uint4_fetch_and_check(NR_registry key, UINT4 min, UINT4 max, int log_fac, int die, UINT4 *val);
   383  int nr_reg_uint8_fetch_and_check(NR_registry key, UINT8 min, UINT8 max, int log_fac, int die, UINT8 *val);
   385 +#ifdef WIN32
   386 +int snprintf(char *buffer, size_t n, const char *format, ...);
   387 +const char *inet_ntop(int af, const void *src, char *dst, size_t size);
   388  #endif
   390 +#endif
   391 +

mercurial