Remove pcre and update tests where necessary

This commit is contained in:
John Johansen 2010-07-31 16:00:52 -07:00
parent 06ebb0b6d6
commit b5c780d2a1
16 changed files with 24 additions and 6206 deletions

View file

@ -1,6 +1,5 @@
This license applies to all source files within the SubDomain parser
package, with the exception of md5.c and the files in the pcre/
subdirectory, as they are covered under their own respective licenses.
package.
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991

View file

@ -82,9 +82,6 @@ OBJECTS = parser_lex.o parser_yacc.o parser_main.o parser_interface.o \
AAREDIR= libapparmor_re
AAREOBJECTS = ${AAREDIR}/libapparmor_re.a
PCREDIR= pcre
PCREOBJECTS = ${PCREDIR}/pcre.o
LEX_C_FILES = parser_lex.c
YACC_C_FILES = parser_yacc.c parser_yacc.h
@ -94,7 +91,7 @@ DISABLED_TESTS =
TEST_OBJECTS = $(filter-out parser_lex.o, \
$(filter-out parser_yacc.o, \
$(filter-out parser_main.o, ${OBJECTS} ${PCREOBJECTS})))
$(filter-out parser_main.o, ${OBJECTS})))
ifdef V
VERBOSE = 1
@ -140,10 +137,10 @@ docs: manpages htmlmanpages pdf
all: main docs tests
apparmor_parser: $(OBJECTS) $(PCREOBJECTS) $(AAREOBJECTS)
apparmor_parser: $(OBJECTS) $(AAREOBJECTS)
rm -f ./libstdc++.a
ln -s `g++ -print-file-name=libstdc++.a`
g++ $(EXTRA_CFLAGS) -o $@ $(OBJECTS) $(PCREOBJECTS) $(LIBS) \
g++ $(EXTRA_CFLAGS) -o $@ $(OBJECTS) $(LIBS) \
${LEXLIB} $(AAREOBJECTS) -static-libgcc -L.
parser_yacc.c parser_yacc.h: parser_yacc.y parser.h
@ -216,8 +213,8 @@ tst_variable: parser_variable.c parser.h $(filter-out parser_variable.o, ${TEST_
tst_misc: parser_misc.c parser.h parser_yacc.h af_names.h cap_names.h
$(Q)$(CC) -DUNIT_TEST $(EXTRA_CFLAGS) $(TEST_FLAGS) -o $@ $< $(BUILD_OUTPUT)
tst_regex: parser_regex.c parser.h parser_yacc.h $(PCREOBJECTS)
$(Q)$(CC) -DUNIT_TEST $(EXTRA_CFLAGS) $(TEST_FLAGS) -o $@ $< $(PCREOBJECTS) $(BUILD_OUTPUT)
tst_regex: parser_regex.c parser.h parser_yacc.h
$(Q)$(CC) -DUNIT_TEST $(EXTRA_CFLAGS) $(TEST_FLAGS) -o $@ $< $(BUILD_OUTPUT)
.SILENT: check
.PHONY: check
@ -237,11 +234,6 @@ check: tests
$(AAREOBJECTS):
make -C $(AAREDIR)
.SILENT: $(PCREOBJECTS)
.PHONY: $(PCREOBJECTS)
$(PCREOBJECTS):
make -C $(PCREDIR) "CFLAGS=$(EXTRA_CFLAGS)"
.PHONY: install-rhel4
install-rhel4: install-redhat
@ -304,7 +296,6 @@ clean: _clean
rm -f af_names.h
rm -f cap_names.h
-rm -rf techdoc.{aux,log,pdf,toc,txt} techdoc/
make -s -C $(PCREDIR) clean
make -s -C $(AAREDIR) clean
make -s -C po clean

View file

@ -11,11 +11,6 @@ issues should be directed to security@suse.de or secure@novell.com,
where we will attempt to conform to the RFP vulnerability disclosure
protocol: http://www.wiretrip.net/rfp/policy.html
The parser uses the PCRE (Perl Compatible Regular Expression) engine,
which was written by Philip Hazel and is copyright by the University
of Cambridge, England. For more information on the PCRE engine, see
<ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/>
Thanks.
-- The AppArmor development team

View file

@ -23,7 +23,6 @@
#include <netinet/in.h>
#include <sys/resource.h>
#include "pcre/internal.h"
#include "immunix.h"
#include "libapparmor_re/apparmor_re.h"
@ -44,7 +43,6 @@ struct named_transition {
struct cod_pattern {
char *regex; // posix regex
pcre *compiled; // compiled regex, size is compiled->size
};
struct cod_entry {
@ -175,9 +173,10 @@ struct var_string {
#define OPTION_OFILE 5
#define AARE_NONE 0
#define AARE_PCRE 1
#define AARE_DFA 2
#define BOOL int
#define FLAG_CHANGEHAT_1_4 2
#define FLAG_CHANGEHAT_1_5 3
extern int flag_changehat_version;

View file

@ -455,57 +455,6 @@ inline int sd_write_listend(sd_serialize *p)
return 1;
}
int sd_serialize_pattern(sd_serialize *p, pcre *pat)
{
if (!sd_write_struct(p, "pcre"))
return 0;
if (!sd_write32(p, pat->size - sizeof(pcre)))
return 0;
if (!sd_write32(p, pat->magic_number))
return 0;
if (!sd_write32(p, pat->options))
return 0;
if (!sd_write16(p, pat->top_bracket))
return 0;
if (!sd_write16(p, pat->top_backref))
return 0;
if (!sd_write8(p, pat->first_char))
return 0;
if (!sd_write8(p, pat->req_char))
return 0;
if (!sd_write8(p, pat->code[0]))
return 0;
if (!sd_write_blob(p, &pat->code[1], pat->size - sizeof(pcre), NULL))
return 0;
if (!sd_write_structend(p))
return 0;
return 1;
}
int sd_serialize_file_entry(sd_serialize *p, struct cod_entry *file_entry)
{
PDEBUG("Writing file entry. name '%s'\n", file_entry->name);
if (!sd_write_struct(p, "fe"))
return 0;
if (!sd_write_string(p, file_entry->name, NULL))
return 0;
if (!sd_write32(p, file_entry->mode))
return 0;
if (!sd_write32(p, file_entry->pattern_type))
return 0;
if (file_entry->pattern_type == ePatternRegex) {
if (!sd_write_string(p, file_entry->pat.regex, NULL))
return 0;
if (!sd_serialize_pattern(p, file_entry->pat.compiled))
return 0;
}
if (!sd_write_structend(p))
return 0;
return 1;
}
int sd_serialize_dfa(sd_serialize *p, void *dfa, size_t size)
{
if (dfa && !sd_write_aligned_blob(p, dfa, size, "aadfa"))
@ -598,18 +547,6 @@ int count_tailglob_ents(struct cod_entry *list)
return count;
}
int count_pcre_ents(struct cod_entry *list)
{
struct cod_entry *entry;
int count = 0;
list_for_each(list, entry) {
if (entry->pattern_type == ePatternRegex) {
count++;
}
}
return count;
}
int sd_serialize_profile(sd_serialize *p, struct codomain *profile,
int flattened)
{
@ -728,47 +665,8 @@ int sd_serialize_profile(sd_serialize *p, struct codomain *profile,
if (!sd_serialize_xtable(p, profile->exec_table))
return 0;
} else {
/* pcre globbing entries */
if (count_pcre_ents(profile->entries)) {
if (!sd_write_list(p, "pgent"))
return 0;
list_for_each(profile->entries, entry) {
if (entry->pattern_type == ePatternRegex) {
if (!sd_serialize_file_entry(p, entry))
return 0;
}
}
if (!sd_write_listend(p))
return 0;
}
/* simple globbing entries */
if (count_tailglob_ents(profile->entries)) {
if (!sd_write_list(p, "sgent"))
return 0;
list_for_each(profile->entries, entry) {
if (entry->pattern_type == ePatternTailGlob) {
if (!sd_serialize_file_entry(p, entry))
return 0;
}
}
if (!sd_write_listend(p))
return 0;
}
/* basic file entries */
if (count_file_ents(profile->entries)) {
if (!sd_write_list(p, "fent"))
return 0;
list_for_each(profile->entries, entry) {
if (entry->pattern_type == ePatternBasic) {
if (!sd_serialize_file_entry(p, entry))
return 0;
}
}
if (!sd_write_listend(p))
return 0;
}
PERROR(_("Unknown pattern type\n"));
return 1;
}
if (profile->hat_table && regex_type != AARE_DFA) {

View file

@ -30,6 +30,7 @@
#include <fcntl.h>
#include <mntent.h>
#include <libintl.h>
#include <linux/limits.h>
#include <locale.h>
#define _(s) gettext(s)
@ -53,7 +54,6 @@
#define MATCH_STRING "/sys/kernel/security/" MODULE_NAME "/matching"
#define FLAGS_FILE "/sys/kernel/security/" MODULE_NAME "/features"
#define MOUNTED_FS "/proc/mounts"
#define PCRE "pattern=pcre"
#define AADFA "pattern=aadfa"
#define PRIVILEGED_OPS (write_cache || kernel_load)
@ -607,9 +607,6 @@ static void get_match_string(void) {
out:
if (match_string) {
if (strstr(match_string, PCRE))
regex_type = AARE_PCRE;
if (strstr(match_string, AADFA))
regex_type = AARE_DFA;
@ -658,20 +655,6 @@ fail:
return;
}
/* return 1 --> PCRE should work fine
return 0 --> no PCRE support */
static int regex_support(void) {
/* no match string, predates (or postdates?) the split matching
module design */
if (!match_string)
return 1;
if (regex_type != AARE_NONE)
return 1;
return 0;
}
int process_binary(int option, char *profilename)
{
char *buffer = NULL;
@ -876,10 +859,6 @@ int process_profile(int option, char *profilename)
goto out;
}
if (!regex_support()) {
die_if_any_regex();
}
retval = load_policy(option);
out:

View file

@ -19,6 +19,7 @@
/* assistance routines */
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
@ -27,6 +28,7 @@
#define _(s) gettext(s)
#include <netinet/in.h>
#include <linux/socket.h>
#include <linux/limits.h>
#include <arpa/inet.h>
#include <linux/capability.h>
@ -632,7 +634,6 @@ struct cod_entry *new_entry(char *namespace, char *id, int mode, char *link_id)
entry->pattern_type = ePatternInvalid;
entry->pat.regex = NULL;
entry->pat.compiled = NULL;
entry->next = NULL;
@ -658,7 +659,6 @@ struct cod_entry *copy_cod_entry(struct cod_entry *orig)
/* XXX - need to create copies of the patterns, too */
entry->pattern_type = orig->pattern_type;
entry->pat.regex = NULL;
entry->pat.compiled = NULL;
entry->next = orig->next;
@ -679,8 +679,6 @@ void free_cod_entries(struct cod_entry *list)
free(list->link_name);
if (list->pat.regex)
free(list->pat.regex);
if (list->pat.compiled)
free(list->pat.compiled);
free(list);
}

View file

@ -21,6 +21,7 @@
#include <stdarg.h>
#include <string.h>
#include <libintl.h>
#include <linux/limits.h>
#define _(s) gettext(s)
/* #define DEBUG */
@ -74,7 +75,6 @@ static void filter_slashes(char *path)
{
char *sptr, *dptr;
BOOL seen_slash = 0;
int len;
if (!path || (strlen(path) < 2))
return;
@ -106,19 +106,6 @@ static void filter_slashes(char *path)
}
}
*dptr = 0;
if (regex_type != AARE_DFA) {
/* eliminate trailing slashes for versions of apparmor that
* do not use the dfa engine.
* Versions of apparmor which use the dfa engine use the
* trailing / to differentiate between file and directory
* matches
*/
len = strlen(path);
if (len > 2 && path[len -1] == '/') {
path[len - 1] = 0;
}
}
}
static pattern_t convert_aaregex_to_pcre(const char *aare, int anchor,
@ -416,82 +403,6 @@ out:
return ptype;
}
static int process_pcre_entry(struct cod_entry *entry)
{
char tbuf[PATH_MAX + 3]; /* +3 for ^, $ and \0 */
int ret = TRUE;
pattern_t ptype;
int pos;
if (!entry) /* shouldn't happen */
return TRUE;
ptype = convert_aaregex_to_pcre(entry->name, 1, tbuf, PATH_MAX+3, &pos);
if (ptype == ePatternInvalid)
return FALSE;
entry->pattern_type = ptype;
/*
* Only use buffer (tbuf) that we built above, if we
* identified a pattern requiring full regex support.
*/
if (ptype == ePatternRegex) {
int pattlen = strlen(tbuf);
if ((entry->pat.regex = malloc(pattlen + 1))) {
const char *errorreason;
int errpos;
strcpy(entry->pat.regex, tbuf);
if ((entry->pat.compiled =
pcre_compile(entry->pat.regex, 0,
&errorreason, &errpos,
NULL))) {
/* NULL out tables, kernel will use a
* private version
*/
entry->pat.compiled->tables = NULL;
} else {
int i;
PERROR(_("%s: Failed to compile regex '%s' [original: '%s']\n"),
progname, entry->pat.regex,
entry->name);
PERROR(_("%s: error near "),
progname);
for (i = 0; i < errpos; i++) {
fputc('.', stderr);
}
fputc('^', stderr);
fputc('\n', stderr);
PERROR(_("%s: error reason: '%s'\n"),
progname, errorreason);
free(entry->pat.regex);
entry->pat.regex = NULL;
ret = FALSE;
}
} else {
PERROR(_("%s: Failed to compile regex '%s' [original: '%s'] - malloc failed\n"),
progname, entry->pat.regex, entry->name);
ret = FALSE;
}
} else {
/* not a regex, scan input for any escape characters
* and remove, and reduce double \\ to a single */
filter_escapes(entry->name);
} /* ptype == ePatternRegex */
return ret;
}
static const char *local_name(const char *name)
{
const char *t;
@ -650,18 +561,13 @@ static int process_dfa_entry(aare_ruleset_t *dfarules, struct cod_entry *entry)
int post_process_entries(struct codomain *cod)
{
int ret = TRUE, rc;
int ret = TRUE;
struct cod_entry *entry;
int count = 0;
list_for_each(cod->entries, entry) {
if (regex_type == AARE_DFA) {
rc = process_dfa_entry(cod->dfarules, entry);
} else {
filter_slashes(entry->name);
rc = process_pcre_entry(entry);
}
if (!rc)
if (regex_type == AARE_DFA &&
!process_dfa_entry(cod->dfarules, entry))
ret = FALSE;
count++;
}
@ -777,7 +683,7 @@ static int test_filter_slashes(void)
test_string = strdup("///foo//////f//oo////////////////");
filter_slashes(test_string);
MY_TEST(strcmp(test_string, "/foo/f/oo") == 0, "simple tests");
MY_TEST(strcmp(test_string, "/foo/f/oo/") == 0, "simple tests");
test_string = strdup("/foo/f/oo");
filter_slashes(test_string);
@ -809,13 +715,11 @@ static int test_filter_slashes(void)
test_string = strdup("/a/");
filter_slashes(test_string);
MY_TEST(strcmp(test_string, "/a") == 0, "simple test for /a/");
MY_TEST(strcmp(test_string, "/a/") == 0, "simple test for /a/");
return rc;
}
int regex_type = AARE_PCRE;
int main(void)
{
int rc = 0;

View file

@ -23,6 +23,7 @@
#include <string.h>
#include <errno.h>
#include <libintl.h>
#include <linux/limits.h>
#define _(s) gettext(s)
#include "immunix.h"

View file

@ -17,10 +17,14 @@
* along with this program; if not, contact Novell, Inc.
*/
#include <ctype.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <libintl.h>
#include <linux/limits.h>
#define _(s) gettext(s)
/* #define DEBUG */

View file

@ -1,7 +0,0 @@
all: pcre.o
pcre.o: pcre.c
$(CC) -c $(CFLAGS) $<
clean:
rm -f pcre.o

View file

@ -1,183 +0,0 @@
/*************************************************
* Perl-Compatible Regular Expressions *
*************************************************/
/* This file is automatically written by the dftables auxiliary
program. If you edit it by hand, you might like to edit the Makefile to
prevent its ever being regenerated.
This file is #included in the compilation of pcre.c to build the default
character tables which are used when no tables are passed to the compile
function. */
static unsigned char pcre_default_tables[] = {
/* This table is a lower casing table. */
0, 1, 2, 3, 4, 5, 6, 7,
8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23,
24, 25, 26, 27, 28, 29, 30, 31,
32, 33, 34, 35, 36, 37, 38, 39,
40, 41, 42, 43, 44, 45, 46, 47,
48, 49, 50, 51, 52, 53, 54, 55,
56, 57, 58, 59, 60, 61, 62, 63,
64, 97, 98, 99,100,101,102,103,
104,105,106,107,108,109,110,111,
112,113,114,115,116,117,118,119,
120,121,122, 91, 92, 93, 94, 95,
96, 97, 98, 99,100,101,102,103,
104,105,106,107,108,109,110,111,
112,113,114,115,116,117,118,119,
120,121,122,123,124,125,126,127,
128,129,130,131,132,133,134,135,
136,137,138,139,140,141,142,143,
144,145,146,147,148,149,150,151,
152,153,154,155,156,157,158,159,
160,161,162,163,164,165,166,167,
168,169,170,171,172,173,174,175,
176,177,178,179,180,181,182,183,
184,185,186,187,188,189,190,191,
192,193,194,195,196,197,198,199,
200,201,202,203,204,205,206,207,
208,209,210,211,212,213,214,215,
216,217,218,219,220,221,222,223,
224,225,226,227,228,229,230,231,
232,233,234,235,236,237,238,239,
240,241,242,243,244,245,246,247,
248,249,250,251,252,253,254,255,
/* This table is a case flipping table. */
0, 1, 2, 3, 4, 5, 6, 7,
8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23,
24, 25, 26, 27, 28, 29, 30, 31,
32, 33, 34, 35, 36, 37, 38, 39,
40, 41, 42, 43, 44, 45, 46, 47,
48, 49, 50, 51, 52, 53, 54, 55,
56, 57, 58, 59, 60, 61, 62, 63,
64, 97, 98, 99,100,101,102,103,
104,105,106,107,108,109,110,111,
112,113,114,115,116,117,118,119,
120,121,122, 91, 92, 93, 94, 95,
96, 65, 66, 67, 68, 69, 70, 71,
72, 73, 74, 75, 76, 77, 78, 79,
80, 81, 82, 83, 84, 85, 86, 87,
88, 89, 90,123,124,125,126,127,
128,129,130,131,132,133,134,135,
136,137,138,139,140,141,142,143,
144,145,146,147,148,149,150,151,
152,153,154,155,156,157,158,159,
160,161,162,163,164,165,166,167,
168,169,170,171,172,173,174,175,
176,177,178,179,180,181,182,183,
184,185,186,187,188,189,190,191,
192,193,194,195,196,197,198,199,
200,201,202,203,204,205,206,207,
208,209,210,211,212,213,214,215,
216,217,218,219,220,221,222,223,
224,225,226,227,228,229,230,231,
232,233,234,235,236,237,238,239,
240,241,242,243,244,245,246,247,
248,249,250,251,252,253,254,255,
/* This table contains bit maps for various character classes.
Each map is 32 bytes long and the bits run from the least
significant end of each byte. The classes that have their own
maps are: space, xdigit, digit, upper, lower, word, graph
print, punct, and cntrl. Other classes are built from combinations. */
0x00,0x3e,0x00,0x00,0x01,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x03,
0x7e,0x00,0x00,0x00,0x7e,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x03,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xfe,0xff,0xff,0x07,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0x07,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x03,
0xfe,0xff,0xff,0x87,0xfe,0xff,0xff,0x07,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0xfe,0xff,0x00,0xfc,
0x01,0x00,0x00,0xf8,0x01,0x00,0x00,0x78,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
/* This table identifies various classes of character by individual bits:
0x01 white space character
0x02 letter
0x04 decimal digit
0x08 hexadecimal digit
0x10 alphanumeric or '_'
0x80 regular expression metacharacter or binary zero
*/
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 0- 7 */
0x00,0x01,0x01,0x01,0x01,0x01,0x00,0x00, /* 8- 15 */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 16- 23 */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 24- 31 */
0x01,0x00,0x00,0x00,0x80,0x00,0x00,0x00, /* - ' */
0x80,0x80,0x80,0x80,0x00,0x00,0x80,0x00, /* ( - / */
0x1c,0x1c,0x1c,0x1c,0x1c,0x1c,0x1c,0x1c, /* 0 - 7 */
0x1c,0x1c,0x00,0x00,0x00,0x00,0x00,0x80, /* 8 - ? */
0x00,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x12, /* @ - G */
0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12, /* H - O */
0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12, /* P - W */
0x12,0x12,0x12,0x80,0x00,0x00,0x80,0x10, /* X - _ */
0x00,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x12, /* ` - g */
0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12, /* h - o */
0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12, /* p - w */
0x12,0x12,0x12,0x80,0x80,0x00,0x00,0x00, /* x -127 */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 128-135 */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 136-143 */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 144-151 */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 152-159 */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 160-167 */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 168-175 */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 176-183 */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 184-191 */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 192-199 */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 200-207 */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 208-215 */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 216-223 */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 224-231 */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 232-239 */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 240-247 */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};/* 248-255 */
/* End of chartables.c */

View file

@ -1,48 +0,0 @@
/* config.h. Generated automatically by configure. */
/* On Unix systems config.in is converted by configure into config.h. PCRE is
written in Standard C, but there are a few non-standard things it can cope
with, allowing it to run on SunOS4 and other "close to standard" systems.
On a non-Unix system you should just copy this file into config.h, and set up
the macros the way you need them. You should normally change the definitions of
HAVE_STRERROR and HAVE_MEMMOVE to 1. Unfortunately, because of the way autoconf
works, these cannot be made the defaults. If your system has bcopy() and not
memmove(), change the definition of HAVE_BCOPY instead of HAVE_MEMMOVE. If your
system has neither bcopy() nor memmove(), leave them both as 0; an emulation
function will be used. */
/* Define to empty if the keyword does not work. */
/* #undef const */
/* Define to `unsigned' if <stddef.h> doesn't define size_t. */
/* #undef size_t */
/* The following two definitions are mainly for the benefit of SunOS4, which
doesn't have the strerror() or memmove() functions that should be present in
all Standard C libraries. The macros HAVE_STRERROR and HAVE_MEMMOVE should
normally be defined with the value 1 for other systems, but unfortunately we
can't make this the default because "configure" files generated by autoconf
will only change 0 to 1; they won't change 1 to 0 if the functions are not
found. */
#define HAVE_STRERROR 1
#define HAVE_MEMMOVE 1
/* There are some non-Unix systems that don't even have bcopy(). If this macro
is false, an emulation is used. If HAVE_MEMMOVE is set to 1, the value of
HAVE_BCOPY is not relevant. */
#define HAVE_BCOPY 1
/* The value of NEWLINE determines the newline character. The default is to
leave it up to the compiler, but some sites want to force a particular value.
On Unix systems, "configure" can be used to override this default. */
#ifndef NEWLINE
#define NEWLINE '\n'
#endif
/* End */

View file

@ -1,412 +0,0 @@
/*************************************************
* Perl-Compatible Regular Expressions *
*************************************************/
/* This is a library of functions to support regular expressions whose syntax
and semantics are as close as possible to those of the Perl 5 language. See
the file Tech.Notes for some information on the internals.
Written by: Philip Hazel <ph10@cam.ac.uk>
Copyright (c) 1997-2001 University of Cambridge
-----------------------------------------------------------------------------
Permission is granted to anyone to use this software for any purpose on any
computer system, and to redistribute it freely, subject to the following
restrictions:
1. This software is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
2. The origin of this software must not be misrepresented, either by
explicit claim or by omission.
3. Altered versions must be plainly marked as such, and must not be
misrepresented as being the original software.
4. If PCRE is embedded in any software that is released under the GNU
General Purpose Licence (GPL), then the terms of that licence shall
supersede any condition above with which it is incompatible.
-----------------------------------------------------------------------------
*/
/* This header contains definitions that are shared between the different
modules, but which are not relevant to the outside. */
/* Get the definitions provided by running "configure" */
#include "config.h"
/* To cope with SunOS4 and other systems that lack memmove() but have bcopy(),
define a macro for memmove() if HAVE_MEMMOVE is false, provided that HAVE_BCOPY
is set. Otherwise, include an emulating function for those systems that have
neither (there some non-Unix environments where this is the case). This assumes
that all calls to memmove are moving strings upwards in store, which is the
case in PCRE. */
#if ! HAVE_MEMMOVE
#undef memmove /* some systems may have a macro */
#if HAVE_BCOPY
#define memmove(a, b, c) bcopy(b, a, c)
#else
void *
pcre_memmove(unsigned char *dest, const unsigned char *src, size_t n)
{
int i;
dest += n;
src += n;
for (i = 0; i < n; ++i) *(--dest) = *(--src);
}
#define memmove(a, b, c) pcre_memmove(a, b, c)
#endif
#endif
/* Standard C headers plus the external interface definition */
#include <ctype.h>
#include <limits.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "pcre.h"
/* In case there is no definition of offsetof() provided - though any proper
Standard C system should have one. */
#ifndef offsetof
#define offsetof(p_type,field) ((size_t)&(((p_type *)0)->field))
#endif
/* These are the public options that can change during matching. */
#define PCRE_IMS (PCRE_CASELESS|PCRE_MULTILINE|PCRE_DOTALL)
/* Private options flags start at the most significant end of the four bytes,
but skip the top bit so we can use ints for convenience without getting tangled
with negative values. The public options defined in pcre.h start at the least
significant end. Make sure they don't overlap, though now that we have expanded
to four bytes there is plenty of space. */
#define PCRE_FIRSTSET 0x40000000 /* first_char is set */
#define PCRE_REQCHSET 0x20000000 /* req_char is set */
#define PCRE_STARTLINE 0x10000000 /* start after \n for multiline */
#define PCRE_INGROUP 0x08000000 /* compiling inside a group */
#define PCRE_ICHANGED 0x04000000 /* i option changes within regex */
/* Options for the "extra" block produced by pcre_study(). */
#define PCRE_STUDY_MAPPED 0x01 /* a map of starting chars exists */
/* Masks for identifying the public options which are permitted at compile
time, run time or study time, respectively. */
#define PUBLIC_OPTIONS \
(PCRE_CASELESS|PCRE_EXTENDED|PCRE_ANCHORED|PCRE_MULTILINE| \
PCRE_DOTALL|PCRE_DOLLAR_ENDONLY|PCRE_EXTRA|PCRE_UNGREEDY|PCRE_UTF8)
#define PUBLIC_EXEC_OPTIONS \
(PCRE_ANCHORED|PCRE_NOTBOL|PCRE_NOTEOL|PCRE_NOTEMPTY)
#define PUBLIC_STUDY_OPTIONS 0 /* None defined */
/* Magic number to provide a small check against being handed junk. */
#define MAGIC_NUMBER 0x50435245UL /* 'PCRE' */
/* Miscellaneous definitions */
typedef int BOOL;
#define FALSE 0
#define TRUE 1
/* Escape items that are just an encoding of a particular data value. Note that
ESC_N is defined as yet another macro, which is set in config.h to either \n
(the default) or \r (which some people want). */
#ifndef ESC_E
#define ESC_E 27
#endif
#ifndef ESC_F
#define ESC_F '\f'
#endif
#ifndef ESC_N
#define ESC_N NEWLINE
#endif
#ifndef ESC_R
#define ESC_R '\r'
#endif
#ifndef ESC_T
#define ESC_T '\t'
#endif
/* These are escaped items that aren't just an encoding of a particular data
value such as \n. They must have non-zero values, as check_escape() returns
their negation. Also, they must appear in the same order as in the opcode
definitions below, up to ESC_z. The final one must be ESC_REF as subsequent
values are used for \1, \2, \3, etc. There is a test in the code for an escape
greater than ESC_b and less than ESC_Z to detect the types that may be
repeated. If any new escapes are put in-between that don't consume a character,
that code will have to change. */
enum { ESC_A = 1, ESC_B, ESC_b, ESC_D, ESC_d, ESC_S, ESC_s, ESC_W, ESC_w,
ESC_Z, ESC_z, ESC_REF };
/* Opcode table: OP_BRA must be last, as all values >= it are used for brackets
that extract substrings. Starting from 1 (i.e. after OP_END), the values up to
OP_EOD must correspond in order to the list of escapes immediately above. */
enum {
OP_END, /* End of pattern */
/* Values corresponding to backslashed metacharacters */
OP_SOD, /* Start of data: \A */
OP_NOT_WORD_BOUNDARY, /* \B */
OP_WORD_BOUNDARY, /* \b */
OP_NOT_DIGIT, /* \D */
OP_DIGIT, /* \d */
OP_NOT_WHITESPACE, /* \S */
OP_WHITESPACE, /* \s */
OP_NOT_WORDCHAR, /* \W */
OP_WORDCHAR, /* \w */
OP_EODN, /* End of data or \n at end of data: \Z. */
OP_EOD, /* End of data: \z */
OP_OPT, /* Set runtime options */
OP_CIRC, /* Start of line - varies with multiline switch */
OP_DOLL, /* End of line - varies with multiline switch */
OP_ANY, /* Match any character */
OP_CHARS, /* Match string of characters */
OP_NOT, /* Match anything but the following char */
OP_STAR, /* The maximizing and minimizing versions of */
OP_MINSTAR, /* all these opcodes must come in pairs, with */
OP_PLUS, /* the minimizing one second. */
OP_MINPLUS, /* This first set applies to single characters */
OP_QUERY,
OP_MINQUERY,
OP_UPTO, /* From 0 to n matches */
OP_MINUPTO,
OP_EXACT, /* Exactly n matches */
OP_NOTSTAR, /* The maximizing and minimizing versions of */
OP_NOTMINSTAR, /* all these opcodes must come in pairs, with */
OP_NOTPLUS, /* the minimizing one second. */
OP_NOTMINPLUS, /* This first set applies to "not" single characters */
OP_NOTQUERY,
OP_NOTMINQUERY,
OP_NOTUPTO, /* From 0 to n matches */
OP_NOTMINUPTO,
OP_NOTEXACT, /* Exactly n matches */
OP_TYPESTAR, /* The maximizing and minimizing versions of */
OP_TYPEMINSTAR, /* all these opcodes must come in pairs, with */
OP_TYPEPLUS, /* the minimizing one second. These codes must */
OP_TYPEMINPLUS, /* be in exactly the same order as those above. */
OP_TYPEQUERY, /* This set applies to character types such as \d */
OP_TYPEMINQUERY,
OP_TYPEUPTO, /* From 0 to n matches */
OP_TYPEMINUPTO,
OP_TYPEEXACT, /* Exactly n matches */
OP_CRSTAR, /* The maximizing and minimizing versions of */
OP_CRMINSTAR, /* all these opcodes must come in pairs, with */
OP_CRPLUS, /* the minimizing one second. These codes must */
OP_CRMINPLUS, /* be in exactly the same order as those above. */
OP_CRQUERY, /* These are for character classes and back refs */
OP_CRMINQUERY,
OP_CRRANGE, /* These are different to the three seta above. */
OP_CRMINRANGE,
OP_CLASS, /* Match a character class */
OP_REF, /* Match a back reference */
OP_RECURSE, /* Match this pattern recursively */
OP_ALT, /* Start of alternation */
OP_KET, /* End of group that doesn't have an unbounded repeat */
OP_KETRMAX, /* These two must remain together and in this */
OP_KETRMIN, /* order. They are for groups the repeat for ever. */
/* The assertions must come before ONCE and COND */
OP_ASSERT, /* Positive lookahead */
OP_ASSERT_NOT, /* Negative lookahead */
OP_ASSERTBACK, /* Positive lookbehind */
OP_ASSERTBACK_NOT, /* Negative lookbehind */
OP_REVERSE, /* Move pointer back - used in lookbehind assertions */
/* ONCE and COND must come after the assertions, with ONCE first, as there's
a test for >= ONCE for a subpattern that isn't an assertion. */
OP_ONCE, /* Once matched, don't back up into the subpattern */
OP_COND, /* Conditional group */
OP_CREF, /* Used to hold an extraction string number (cond ref) */
OP_BRAZERO, /* These two must remain together and in this */
OP_BRAMINZERO, /* order. */
OP_BRANUMBER, /* Used for extracting brackets whose number is greater
than can fit into an opcode. */
OP_BRA /* This and greater values are used for brackets that
extract substrings up to a basic limit. After that,
use is made of OP_BRANUMBER. */
};
/* The highest extraction number before we have to start using additional
bytes. (Originally PCRE didn't have support for extraction counts highter than
this number.) The value is limited by the number of opcodes left after OP_BRA,
i.e. 255 - OP_BRA. We actually set it a bit lower to leave room for additional
opcodes. */
#define EXTRACT_BASIC_MAX 150
/* The texts of compile-time error messages are defined as macros here so that
they can be accessed by the POSIX wrapper and converted into error codes. Yes,
I could have used error codes in the first place, but didn't feel like changing
just to accommodate the POSIX wrapper. */
#define ERR1 "\\ at end of pattern"
#define ERR2 "\\c at end of pattern"
#define ERR3 "unrecognized character follows \\"
#define ERR4 "numbers out of order in {} quantifier"
#define ERR5 "number too big in {} quantifier"
#define ERR6 "missing terminating ] for character class"
#define ERR7 "invalid escape sequence in character class"
#define ERR8 "range out of order in character class"
#define ERR9 "nothing to repeat"
#define ERR10 "operand of unlimited repeat could match the empty string"
#define ERR11 "internal error: unexpected repeat"
#define ERR12 "unrecognized character after (?"
#define ERR13 "unused error"
#define ERR14 "missing )"
#define ERR15 "back reference to non-existent subpattern"
#define ERR16 "erroffset passed as NULL"
#define ERR17 "unknown option bit(s) set"
#define ERR18 "missing ) after comment"
#define ERR19 "parentheses nested too deeply"
#define ERR20 "regular expression too large"
#define ERR21 "failed to get memory"
#define ERR22 "unmatched parentheses"
#define ERR23 "internal error: code overflow"
#define ERR24 "unrecognized character after (?<"
#define ERR25 "lookbehind assertion is not fixed length"
#define ERR26 "malformed number after (?("
#define ERR27 "conditional group contains more than two branches"
#define ERR28 "assertion expected after (?("
#define ERR29 "(?p must be followed by )"
#define ERR30 "unknown POSIX class name"
#define ERR31 "POSIX collating elements are not supported"
#define ERR32 "this version of PCRE is not compiled with PCRE_UTF8 support"
#define ERR33 "characters with values > 255 are not yet supported in classes"
#define ERR34 "character value in \\x{...} sequence is too large"
#define ERR35 "invalid condition (?(0)"
/* All character handling must be done as unsigned characters. Otherwise there
are problems with top-bit-set characters and functions such as isspace().
However, we leave the interface to the outside world as char *, because that
should make things easier for callers. We define a short type for unsigned char
to save lots of typing. I tried "uchar", but it causes problems on Digital
Unix, where it is defined in sys/types, so use "uschar" instead. */
typedef unsigned char uschar;
/* The real format of the start of the pcre block; the actual code vector
runs on as long as necessary after the end. */
typedef struct real_pcre {
unsigned long int magic_number;
size_t size;
const unsigned char *tables;
unsigned long int options;
unsigned short int top_bracket;
unsigned short int top_backref;
uschar first_char;
uschar req_char;
uschar code[1];
} real_pcre;
/* The real format of the extra block returned by pcre_study(). */
typedef struct real_pcre_extra {
uschar options;
uschar start_bits[32];
} real_pcre_extra;
/* Structure for passing "static" information around between the functions
doing the compiling, so that they are thread-safe. */
typedef struct compile_data {
const uschar *lcc; /* Points to lower casing table */
const uschar *fcc; /* Points to case-flipping table */
const uschar *cbits; /* Points to character type table */
const uschar *ctypes; /* Points to table of type maps */
} compile_data;
/* Structure for passing "static" information around between the functions
doing the matching, so that they are thread-safe. */
typedef struct match_data {
int errorcode; /* As it says */
int *offset_vector; /* Offset vector */
int offset_end; /* One past the end */
int offset_max; /* The maximum usable for return data */
const uschar *lcc; /* Points to lower casing table */
const uschar *ctypes; /* Points to table of type maps */
BOOL offset_overflow; /* Set if too many extractions */
BOOL notbol; /* NOTBOL flag */
BOOL noteol; /* NOTEOL flag */
BOOL utf8; /* UTF8 flag */
BOOL endonly; /* Dollar not before final \n */
BOOL notempty; /* Empty string match not wanted */
const uschar *start_pattern; /* For use when recursing */
const uschar *start_subject; /* Start of the subject string */
const uschar *end_subject; /* End of the subject string */
const uschar *start_match; /* Start of this match attempt */
const uschar *end_match_ptr; /* Subject position at end match */
int end_offset_top; /* Highwater mark at end of match */
} match_data;
/* Bit definitions for entries in the pcre_ctypes table. */
#define ctype_space 0x01
#define ctype_letter 0x02
#define ctype_digit 0x04
#define ctype_xdigit 0x08
#define ctype_word 0x10 /* alphameric or '_' */
#define ctype_meta 0x80 /* regexp meta char or zero (end pattern) */
/* Offsets for the bitmap tables in pcre_cbits. Each table contains a set
of bits for a class map. Some classes are built by combining these tables. */
#define cbit_space 0 /* [:space:] or \s */
#define cbit_xdigit 32 /* [:xdigit:] */
#define cbit_digit 64 /* [:digit:] or \d */
#define cbit_upper 96 /* [:upper:] */
#define cbit_lower 128 /* [:lower:] */
#define cbit_word 160 /* [:word:] or \w */
#define cbit_graph 192 /* [:graph:] */
#define cbit_print 224 /* [:print:] */
#define cbit_punct 256 /* [:punct:] */
#define cbit_cntrl 288 /* [:cntrl:] */
#define cbit_length 320 /* Length of the cbits table */
/* Offsets of the various tables from the base tables pointer, and
total length. */
#define lcc_offset 0
#define fcc_offset 256
#define cbits_offset 512
#define ctypes_offset (cbits_offset + cbit_length)
#define tables_length (ctypes_offset + 256)
/* End of internal.h */

File diff suppressed because it is too large Load diff

View file

@ -1,113 +0,0 @@
/*************************************************
* Perl-Compatible Regular Expressions *
*************************************************/
/* Copyright (c) 1997-2001 University of Cambridge */
#ifndef _PCRE_H
#define _PCRE_H
/* The file pcre.h is build by "configure". Do not edit it; instead
make changes to pcre.in. */
#define PCRE_MAJOR 3
#define PCRE_MINOR 9
#define PCRE_DATE 02-Jan-2002
/* Win32 uses DLL by default */
#ifdef _WIN32
# ifdef STATIC
# define PCRE_DL_IMPORT
# else
# define PCRE_DL_IMPORT __declspec(dllimport)
# endif
#else
# define PCRE_DL_IMPORT
#endif
/* Have to include stdlib.h in order to ensure that size_t is defined;
it is needed here for malloc. */
#include <stdlib.h>
/* Allow for C++ users */
#ifdef __cplusplus
extern "C" {
#endif
/* Options */
#define PCRE_CASELESS 0x0001
#define PCRE_MULTILINE 0x0002
#define PCRE_DOTALL 0x0004
#define PCRE_EXTENDED 0x0008
#define PCRE_ANCHORED 0x0010
#define PCRE_DOLLAR_ENDONLY 0x0020
#define PCRE_EXTRA 0x0040
#define PCRE_NOTBOL 0x0080
#define PCRE_NOTEOL 0x0100
#define PCRE_UNGREEDY 0x0200
#define PCRE_NOTEMPTY 0x0400
#define PCRE_UTF8 0x0800
/* Exec-time and get-time error codes */
#define PCRE_ERROR_NOMATCH (-1)
#define PCRE_ERROR_NULL (-2)
#define PCRE_ERROR_BADOPTION (-3)
#define PCRE_ERROR_BADMAGIC (-4)
#define PCRE_ERROR_UNKNOWN_NODE (-5)
#define PCRE_ERROR_NOMEMORY (-6)
#define PCRE_ERROR_NOSUBSTRING (-7)
/* Request types for pcre_fullinfo() */
#define PCRE_INFO_OPTIONS 0
#define PCRE_INFO_SIZE 1
#define PCRE_INFO_CAPTURECOUNT 2
#define PCRE_INFO_BACKREFMAX 3
#define PCRE_INFO_FIRSTCHAR 4
#define PCRE_INFO_FIRSTTABLE 5
#define PCRE_INFO_LASTLITERAL 6
/* Types */
struct real_pcre; /* declaration; the definition is private */
struct real_pcre_extra; /* declaration; the definition is private */
typedef struct real_pcre pcre;
typedef struct real_pcre_extra pcre_extra;
/* Store get and free functions. These can be set to alternative malloc/free
functions if required. Some magic is required for Win32 DLL; it is null on
other OS. */
PCRE_DL_IMPORT extern void *(*pcre_malloc)(size_t);
PCRE_DL_IMPORT extern void (*pcre_free)(void *);
#undef PCRE_DL_IMPORT
/* Functions */
extern pcre *pcre_compile(const char *, int, const char **, int *,
const unsigned char *);
extern int pcre_copy_substring(const char *, int *, int, int, char *, int);
extern int pcre_exec(const pcre *, const pcre_extra *, const char *,
int, int, int, int *, int);
extern void pcre_free_substring(const char *);
extern void pcre_free_substring_list(const char **);
extern int pcre_get_substring(const char *, int *, int, int, const char **);
extern int pcre_get_substring_list(const char *, int *, int, const char ***);
extern int pcre_info(const pcre *, int *, int *);
extern int pcre_fullinfo(const pcre *, const pcre_extra *, int, void *);
extern const unsigned char *pcre_maketables(void);
extern pcre_extra *pcre_study(const pcre *, int, const char **);
extern const char *pcre_version(void);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* End of pcre.h */