socsvn commit: r255064 - soc2013/dpl/head/lib/libz
dpl at FreeBSD.org
dpl at FreeBSD.org
Tue Jul 23 14:26:14 UTC 2013
Author: dpl
Date: Tue Jul 23 14:26:13 2013
New Revision: 255064
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255064
Log:
Compartmentalize crc32.
Modified:
soc2013/dpl/head/lib/libz/Makefile
soc2013/dpl/head/lib/libz/crc32.c
soc2013/dpl/head/lib/libz/gzlib.c
soc2013/dpl/head/lib/libz/zconf.h
soc2013/dpl/head/lib/libz/zutil.h
Modified: soc2013/dpl/head/lib/libz/Makefile
==============================================================================
--- soc2013/dpl/head/lib/libz/Makefile Tue Jul 23 13:56:38 2013 (r255063)
+++ soc2013/dpl/head/lib/libz/Makefile Tue Jul 23 14:26:13 2013 (r255064)
@@ -2,6 +2,9 @@
# $FreeBSD: head/lib/libz/Makefile 232263 2012-02-28 18:30:18Z dim $
#
+#TODEL
+CFLAGS+= -Wall -g -fno-color-diagnostics
+
LIB= z
SHLIBDIR?= /lib
SHLIB_MAJOR= 6
@@ -13,8 +16,6 @@
# -Wstrict-prototypes -Wmissing-prototypes
CFLAGS+= -DHAS_snprintf -DHAS_vsnprintf -I${.CURDIR}
-#TODEL
-CFLAGS+= -Wall -g -fno-color-output
WARNS?= 3
CLEANFILES+= example.o example foo.gz minigzip.o minigzip
Modified: soc2013/dpl/head/lib/libz/crc32.c
==============================================================================
--- soc2013/dpl/head/lib/libz/crc32.c Tue Jul 23 13:56:38 2013 (r255063)
+++ soc2013/dpl/head/lib/libz/crc32.c Tue Jul 23 14:26:13 2013 (r255064)
@@ -37,6 +37,8 @@
# define BYFOUR
#endif
#ifdef BYFOUR
+ unsigned long crc32_ OF((unsigned long,
+ const unsigned char FAR *, uInt));
local unsigned long crc32_little OF((unsigned long,
const unsigned char FAR *, unsigned));
local unsigned long crc32_big OF((unsigned long,
@@ -206,6 +208,27 @@
const unsigned char FAR *buf;
uInt len;
{
+ long ret;
+ #ifdef CAPSICUM
+ int forkpid;
+ if ( (forkpid = fork()) == 0 ){
+ cap_enter();
+ #endif
+ ret = crc32_(crc, buf, len);
+ #ifdef CAPSICUM
+ return ret;
+ } else if ( forkpid != 0) {
+ wait(NULL);
+ }
+ #endif
+ return ret;
+}
+
+unsigned long ZEXPORT crc32_(crc, buf, len)
+ unsigned long crc;
+ const unsigned char FAR *buf;
+ uInt len;
+{
if (buf == Z_NULL) return 0UL;
#ifdef DYNAMIC_CRC_TABLE
Modified: soc2013/dpl/head/lib/libz/gzlib.c
==============================================================================
--- soc2013/dpl/head/lib/libz/gzlib.c Tue Jul 23 13:56:38 2013 (r255063)
+++ soc2013/dpl/head/lib/libz/gzlib.c Tue Jul 23 14:26:13 2013 (r255064)
@@ -18,14 +18,6 @@
#endif
#endif
-#if defined(__FreeBSD__)
-# include <osreldate.h>
-# if __FreeBSD_version >= 900041
-# define CAPSICUM
-# include <sys/capability.h>
-# endif
-#endif
-
/* Local functions */
local void gz_reset OF((gz_statep));
local gzFile gz_open OF((const void *, int, const char *));
Modified: soc2013/dpl/head/lib/libz/zconf.h
==============================================================================
--- soc2013/dpl/head/lib/libz/zconf.h Tue Jul 23 13:56:38 2013 (r255063)
+++ soc2013/dpl/head/lib/libz/zconf.h Tue Jul 23 14:26:13 2013 (r255064)
@@ -480,11 +480,25 @@
/*
* This is hard-configured for FreeBSD.
*/
-#define z_off_t off_t
+#define z_off_t off_t
#ifndef _FILE_OFFSET_BITS
#define _FILE_OFFSET_BITS 64
#endif
+/*
+ * With Capsicum, we get a compartmentalized, and securer lib.
+ */
+#if defined(__FreeBSD__)
+# include <osreldate.h>
+# if __FreeBSD_version >= 900041
+# define CAPSICUM
+# include <sys/capability.h>
+# include <unistd.h>
+# include <sys/types.h>
+# include <sys/wait.h>
+# endif
+#endif
+
#ifndef z_off_t
# define z_off_t long
#endif
Modified: soc2013/dpl/head/lib/libz/zutil.h
==============================================================================
--- soc2013/dpl/head/lib/libz/zutil.h Tue Jul 23 13:56:38 2013 (r255063)
+++ soc2013/dpl/head/lib/libz/zutil.h Tue Jul 23 14:26:13 2013 (r255064)
@@ -4,8 +4,8 @@
*/
/* WARNING: this file should *not* be used by applications. It is
- part of the implementation of the compression library and is
- subject to change. Applications should only use zlib.h.
+ part of the implementation of the compression library and is
+ subject to change. Applications should only use zlib.h.
*/
/* @(#) $Id$ */
@@ -14,35 +14,35 @@
#define ZUTIL_H
#ifdef HAVE_HIDDEN
-# define ZLIB_INTERNAL __attribute__((visibility ("hidden")))
+# define ZLIB_INTERNAL __attribute__((visibility ("hidden")))
#else
-# define ZLIB_INTERNAL
+# define ZLIB_INTERNAL
#endif
#include "zlib.h"
#if defined(STDC) && !defined(Z_SOLO)
-# if !(defined(_WIN32_WCE) && defined(_MSC_VER))
-# include <stddef.h>
-# endif
-# include <string.h>
-# include <stdlib.h>
+# if !(defined(_WIN32_WCE) && defined(_MSC_VER))
+# include <stddef.h>
+# endif
+# include <string.h>
+# include <stdlib.h>
#endif
#ifdef Z_SOLO
- typedef long ptrdiff_t; /* guess -- will be caught if guess is wrong */
+ typedef long ptrdiff_t; /* guess -- will be caught if guess is wrong */
#endif
#ifndef local
-# define local static
+# define local static
#endif
/* compile with -Dlocal if your debugger can't find static symbols */
-typedef unsigned char uch;
+typedef unsigned char uch;
typedef uch FAR uchf;
typedef unsigned short ush;
typedef ush FAR ushf;
-typedef unsigned long ulg;
+typedef unsigned long ulg;
extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
/* (size given to avoid silly warnings with Visual C++) */
@@ -50,204 +50,218 @@
#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
#define ERR_RETURN(strm,err) \
- return (strm->msg = ERR_MSG(err), (err))
+ return (strm->msg = ERR_MSG(err), (err))
/* To be used only when the state is known to be valid */
- /* common constants */
+ /* common constants */
#ifndef DEF_WBITS
-# define DEF_WBITS MAX_WBITS
+# define DEF_WBITS MAX_WBITS
#endif
/* default windowBits for decompression. MAX_WBITS is for compression only */
#if MAX_MEM_LEVEL >= 8
-# define DEF_MEM_LEVEL 8
+# define DEF_MEM_LEVEL 8
#else
-# define DEF_MEM_LEVEL MAX_MEM_LEVEL
+# define DEF_MEM_LEVEL MAX_MEM_LEVEL
#endif
/* default memLevel */
#define STORED_BLOCK 0
#define STATIC_TREES 1
-#define DYN_TREES 2
+#define DYN_TREES 2
/* The three kinds of block type */
-#define MIN_MATCH 3
-#define MAX_MATCH 258
+#define MIN_MATCH 3
+#define MAX_MATCH 258
/* The minimum and maximum match lengths */
#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */
- /* target dependencies */
+ /* target dependencies */
#if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32))
-# define OS_CODE 0x00
-# ifndef Z_SOLO
-# if defined(__TURBOC__) || defined(__BORLANDC__)
-# if (__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__))
- /* Allow compilation with ANSI keywords only enabled */
- void _Cdecl farfree( void *block );
- void *_Cdecl farmalloc( unsigned long nbytes );
-# else
-# include <alloc.h>
-# endif
-# else /* MSC or DJGPP */
-# include <malloc.h>
+# define OS_CODE 0x00
+# ifndef Z_SOLO
+# if defined(__TURBOC__) || defined(__BORLANDC__)
+# if (__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__))
+ /* Allow compilation with ANSI keywords only enabled */
+ void _Cdecl farfree( void *block );
+ void *_Cdecl farmalloc( unsigned long nbytes );
+# else
+# include <alloc.h>
+# endif
+# else /* MSC or DJGPP */
+# include <malloc.h>
+# endif
# endif
-# endif
#endif
#ifdef AMIGA
-# define OS_CODE 0x01
+# define OS_CODE 0x01
#endif
#if defined(VAXC) || defined(VMS)
-# define OS_CODE 0x02
-# define F_OPEN(name, mode) \
- fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512")
+# define OS_CODE 0x02
+# define F_OPEN(name, mode) \
+ fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512")
#endif
#if defined(ATARI) || defined(atarist)
-# define OS_CODE 0x05
+# define OS_CODE 0x05
#endif
#ifdef OS2
-# define OS_CODE 0x06
-# if defined(M_I86) && !defined(Z_SOLO)
-# include <malloc.h>
-# endif
+# define OS_CODE 0x06
+# if defined(M_I86) && !defined(Z_SOLO)
+# include <malloc.h>
+# endif
#endif
#if defined(MACOS) || defined(TARGET_OS_MAC)
-# define OS_CODE 0x07
-# ifndef Z_SOLO
-# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
-# include <unix.h> /* for fdopen */
-# else
-# ifndef fdopen
-# define fdopen(fd,mode) NULL /* No fdopen() */
-# endif
+# define OS_CODE 0x07
+# ifndef Z_SOLO
+# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
+# include <unix.h> /* for fdopen */
+# else
+# ifndef fdopen
+# define fdopen(fd,mode) NULL /* No fdopen() */
+# endif
+# endif
# endif
-# endif
#endif
#ifdef TOPS20
-# define OS_CODE 0x0a
+# define OS_CODE 0x0a
#endif
#ifdef WIN32
-# ifndef __CYGWIN__ /* Cygwin is Unix, not Win32 */
-# define OS_CODE 0x0b
-# endif
+# ifndef __CYGWIN__ /* Cygwin is Unix, not Win32 */
+# define OS_CODE 0x0b
+# endif
#endif
#ifdef __50SERIES /* Prime/PRIMOS */
-# define OS_CODE 0x0f
+# define OS_CODE 0x0f
#endif
#if defined(_BEOS_) || defined(RISCOS)
-# define fdopen(fd,mode) NULL /* No fdopen() */
+# define fdopen(fd,mode) NULL /* No fdopen() */
#endif
#if (defined(_MSC_VER) && (_MSC_VER > 600)) && !defined __INTERIX
-# if defined(_WIN32_WCE)
-# define fdopen(fd,mode) NULL /* No fdopen() */
-# ifndef _PTRDIFF_T_DEFINED
- typedef int ptrdiff_t;
-# define _PTRDIFF_T_DEFINED
-# endif
-# else
-# define fdopen(fd,type) _fdopen(fd,type)
-# endif
+# if defined(_WIN32_WCE)
+# define fdopen(fd,mode) NULL /* No fdopen() */
+# ifndef _PTRDIFF_T_DEFINED
+ typedef int ptrdiff_t;
+# define _PTRDIFF_T_DEFINED
+# endif
+# else
+# define fdopen(fd,type) _fdopen(fd,type)
+# endif
#endif
#if defined(__BORLANDC__) && !defined(MSDOS)
- #pragma warn -8004
- #pragma warn -8008
- #pragma warn -8066
+ #pragma warn -8004
+ #pragma warn -8008
+ #pragma warn -8066
+#endif
+
+/*
+ * With Capsicum, we get a compartmentalized, and securer lib.
+ */
+#if defined(__FreeBSD__)
+# include <osreldate.h>
+# if __FreeBSD_version >= 900041
+# define CAPSICUM
+# include <sys/capability.h>
+# include <unistd.h>
+# include <sys/types.h>
+# include <sys/wait.h>
+# endif
#endif
/* provide prototypes for these when building zlib without LFS */
#if !defined(_WIN32) && \
- (!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0)
- ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t));
- ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t));
+ (!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0)
+ ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t));
+ ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t));
#endif
- /* common defaults */
+ /* common defaults */
#ifndef OS_CODE
-# define OS_CODE 0x03 /* assume Unix */
+# define OS_CODE 0x03 /* assume Unix */
#endif
#ifndef F_OPEN
-# define F_OPEN(name, mode) fopen((name), (mode))
+# define F_OPEN(name, mode) fopen((name), (mode))
#endif
- /* functions */
+ /* functions */
#if defined(pyr) || defined(Z_SOLO)
-# define NO_MEMCPY
+# define NO_MEMCPY
#endif
#if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__)
/* Use our own functions for small and medium model with MSC <= 5.0.
- * You may have to use the same strategy for Borland C (untested).
- * The __SC__ check is for Symantec.
- */
-# define NO_MEMCPY
+ * You may have to use the same strategy for Borland C (untested).
+ * The __SC__ check is for Symantec.
+ */
+# define NO_MEMCPY
#endif
#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY)
-# define HAVE_MEMCPY
+# define HAVE_MEMCPY
#endif
#ifdef HAVE_MEMCPY
-# ifdef SMALL_MEDIUM /* MSDOS small or medium model */
-# define zmemcpy _fmemcpy
-# define zmemcmp _fmemcmp
-# define zmemzero(dest, len) _fmemset(dest, 0, len)
-# else
-# define zmemcpy memcpy
-# define zmemcmp memcmp
-# define zmemzero(dest, len) memset(dest, 0, len)
-# endif
+# ifdef SMALL_MEDIUM /* MSDOS small or medium model */
+# define zmemcpy _fmemcpy
+# define zmemcmp _fmemcmp
+# define zmemzero(dest, len) _fmemset(dest, 0, len)
+# else
+# define zmemcpy memcpy
+# define zmemcmp memcmp
+# define zmemzero(dest, len) memset(dest, 0, len)
+# endif
#else
- void ZLIB_INTERNAL zmemcpy OF((Bytef* dest, const Bytef* source, uInt len));
- int ZLIB_INTERNAL zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len));
- void ZLIB_INTERNAL zmemzero OF((Bytef* dest, uInt len));
+ void ZLIB_INTERNAL zmemcpy OF((Bytef* dest, const Bytef* source, uInt len));
+ int ZLIB_INTERNAL zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len));
+ void ZLIB_INTERNAL zmemzero OF((Bytef* dest, uInt len));
#endif
/* Diagnostic functions */
#ifdef DEBUG
-# include <stdio.h>
- extern int ZLIB_INTERNAL z_verbose;
- extern void ZLIB_INTERNAL z_error OF((char *m));
-# define Assert(cond,msg) {if(!(cond)) z_error(msg);}
-# define Trace(x) {if (z_verbose>=0) fprintf x ;}
-# define Tracev(x) {if (z_verbose>0) fprintf x ;}
-# define Tracevv(x) {if (z_verbose>1) fprintf x ;}
-# define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;}
-# define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;}
+# include <stdio.h>
+ extern int ZLIB_INTERNAL z_verbose;
+ extern void ZLIB_INTERNAL z_error OF((char *m));
+# define Assert(cond,msg) {if(!(cond)) z_error(msg);}
+# define Trace(x) {if (z_verbose>=0) fprintf x ;}
+# define Tracev(x) {if (z_verbose>0) fprintf x ;}
+# define Tracevv(x) {if (z_verbose>1) fprintf x ;}
+# define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;}
+# define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;}
#else
-# define Assert(cond,msg)
-# define Trace(x)
-# define Tracev(x)
-# define Tracevv(x)
-# define Tracec(c,x)
-# define Tracecv(c,x)
+# define Assert(cond,msg)
+# define Trace(x)
+# define Tracev(x)
+# define Tracevv(x)
+# define Tracec(c,x)
+# define Tracecv(c,x)
#endif
#ifndef Z_SOLO
- voidpf ZLIB_INTERNAL zcalloc OF((voidpf opaque, unsigned items,
- unsigned size));
- void ZLIB_INTERNAL zcfree OF((voidpf opaque, voidpf ptr));
+ voidpf ZLIB_INTERNAL zcalloc OF((voidpf opaque, unsigned items,
+ unsigned size));
+ void ZLIB_INTERNAL zcfree OF((voidpf opaque, voidpf ptr));
#endif
#define ZALLOC(strm, items, size) \
- (*((strm)->zalloc))((strm)->opaque, (items), (size))
-#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
+ (*((strm)->zalloc))((strm)->opaque, (items), (size))
+#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
#define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
/* Reverse the bytes in a 32-bit value */
#define ZSWAP32(q) ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \
- (((q) & 0xff00) << 8) + (((q) & 0xff) << 24))
+ (((q) & 0xff00) << 8) + (((q) & 0xff) << 24))
#endif /* ZUTIL_H */
More information about the svn-soc-all
mailing list