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.

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

mercurial