speechd-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] sd_generic: fix escaping of data destined for shell.


From: Christopher Brannon
Subject: [PATCH] sd_generic: fix escaping of data destined for shell.
Date: Mon, 23 Aug 2010 07:32:48 -0500

All of the *-generic.conf files quote $DATA with single quotes (').
We shouldn't escape \, ", and `, because these characters are already
interpreted literally by the shell.  We do need to escape single
quotes.  This is done by closing the string, inserting \', and
re-opening the string.
---
 src/modules/generic.c |    8 ++------
 1 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/src/modules/generic.c b/src/modules/generic.c
index 4d17af4..de0a8ac 100644
--- a/src/modules/generic.c
+++ b/src/modules/generic.c
@@ -495,12 +495,8 @@ _generic_child(TModuleDoublePipe dpipe, const size_t 
maxlen)
         /* Escape any quotes */
         message = g_string_new("");
         for(i=0; i<=bytes-1; i++){
-            if (text[i] == '\"')
-                message = g_string_append(message, "\\\"");
-            else if (text[i] == '`')
-                message = g_string_append(message, "\\`");
-            else if (text[i] == '\\')
-                message = g_string_append(message, "\\\\");
+            if (text[i] == '\'')
+                message = g_string_append(message, "'\\''");
            else{
                 g_string_append_printf(message, "%c", text[i]);
             }
-- 
1.7.2.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]