From f4fb20fba83a40f6cbc1953f195f979baeeb3740 Mon Sep 17 00:00:00 2001 From: Jun-ichiro itojun Hagino Date: Mon, 16 Jun 2003 06:36:41 +0000 Subject: - limited number of processes per systrace - escape fixes for special characters markus, sturm ok. from provos --- bin/systrace/util.c | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'bin/systrace/util.c') diff --git a/bin/systrace/util.c b/bin/systrace/util.c index b6bd8b17cd2..563c2757098 100644 --- a/bin/systrace/util.c +++ b/bin/systrace/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.9 2002/10/09 03:52:10 itojun Exp $ */ +/* $OpenBSD: util.c,v 1.10 2003/06/16 06:36:40 itojun Exp $ */ /* * Copyright 2002 Niels Provos * All rights reserved. @@ -33,9 +33,41 @@ #include #include #include +#include #include "util.h" +char * +strescape(char *str) +{ + static char escape[8192]; + int i, p; + + for (p = i = 0; i < strlen(str) && p < sizeof(escape) - 1; i++) { + char a = str[i]; + switch (a) { + case '\r': + a = 'r'; + goto doescape; + case '\n': + a = 'n'; + goto doescape; + case '\\': + case '\"': + doescape: + escape[p++] = '\\'; + if (p >= sizeof(escape) - 1) + errx(1, "%s: string too long: %s", + __func__, str); + default: + escape[p++] = a; + } + } + + escape[p] = '\0'; + return (escape); +} + char * strrpl(char *str, size_t size, char *match, char *value) { -- cgit v1.2.3