summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfche <fche>2007-06-22 19:39:29 +0000
committerfche <fche>2007-06-22 19:39:29 +0000
commit18acf318364cb5337629df5afe1f304952f0e19e (patch)
treebf7f7c2b6ddddda9c0b2c46ddd3906febbcaa7ca
parent126c384c1325e1cdd391dc15a6d601d893b8f985 (diff)
downloadsystemtap-steved-18acf318364cb5337629df5afe1f304952f0e19e.tar.gz
systemtap-steved-18acf318364cb5337629df5afe1f304952f0e19e.tar.xz
systemtap-steved-18acf318364cb5337629df5afe1f304952f0e19e.zip
2007-06-22 Frank Ch. Eigler <fche@elastic.org>
* string.c (_stp_text_str): Fix handling of embedded " and \ characters.
-rw-r--r--runtime/ChangeLog5
-rw-r--r--runtime/string.c19
2 files changed, 19 insertions, 5 deletions
diff --git a/runtime/ChangeLog b/runtime/ChangeLog
index 14c77c29..2e9cf933 100644
--- a/runtime/ChangeLog
+++ b/runtime/ChangeLog
@@ -1,3 +1,8 @@
+2007-06-22 Frank Ch. Eigler <fche@elastic.org>
+
+ * string.c (_stp_text_str): Fix handling of embedded
+ " and \ characters.
+
2007-06-21 David Smith <dsmith@redhat.com>
* lket/b2a/Makefile.in: Regenerated with automake 1.10.
diff --git a/runtime/string.c b/runtime/string.c
index 804af445..13c46dda 100644
--- a/runtime/string.c
+++ b/runtime/string.c
@@ -69,7 +69,7 @@ void _stp_text_str(char *outstr, char *in, int len, int quoted, int user)
len = MAXSTRINGLEN-1;
if (quoted) {
len -= 2;
- *out++ = '\"';
+ *out++ = '"';
}
if (user) {
@@ -82,8 +82,9 @@ void _stp_text_str(char *outstr, char *in, int len, int quoted, int user)
while (c && len > 0) {
int num = 1;
- if (isprint(c) && isascii(c))
- *out++ = c;
+ if (isprint(c) && isascii(c)
+ && c != '"' && c != '\\') /* quoteworthy characters */
+ *out++ = c;
else {
switch (c) {
case '\a':
@@ -93,6 +94,8 @@ void _stp_text_str(char *outstr, char *in, int len, int quoted, int user)
case '\r':
case '\t':
case '\v':
+ case '"':
+ case '\\':
num = 2;
break;
default:
@@ -131,6 +134,12 @@ void _stp_text_str(char *outstr, char *in, int len, int quoted, int user)
case '\v':
*out++ = 'v';
break;
+ case '"':
+ *out++ = '"';
+ break;
+ case '\\':
+ *out++ = '\\';
+ break;
default: /* output octal representation */
if (c > 077)
*out++ = to_oct_digit(c >> 6);
@@ -152,12 +161,12 @@ void _stp_text_str(char *outstr, char *in, int len, int quoted, int user)
if (quoted) {
if (c) {
out = out - 3 + len;
- *out++ = '\"';
+ *out++ = '"';
*out++ = '.';
*out++ = '.';
*out++ = '.';
} else
- *out++ = '\"';
+ *out++ = '"';
}
*out = '\0';
return;