speechd-discuss
[Top][All Lists]
Advanced

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

[PATCH 4/4] Change the way that lines are read in the server.


From: Christopher Brannon
Subject: [PATCH 4/4] Change the way that lines are read in the server.
Date: Tue, 8 Jun 2010 10:03:50 -0500

For the purpose of SSIP, the line terminator is carriage return linefeed.
The code that reads lines of SSIP should not accept a bare linefeed as
the line terminator.
If it does, then it will accept foo\n.\r\n as a complete message, even
though the end-of-data marker is \r\n.\r\n

Thanks to Trevor Saunders for suggesting this fix.
---
 src/server/server.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/server/server.c b/src/server/server.c
index c545b34..4bd245e 100644
--- a/src/server/server.c
+++ b/src/server/server.c
@@ -237,8 +237,9 @@ serve(int fd)
                 spd_free (buf);
                 return -1;
               }
-            if (buf[bytes] == '\n')
-              {
+            /* Note, bytes is a 0-based index into buf. */
+            if ((buf[bytes] == '\n')
+              && (bytes >= 1) && (buf[bytes - 1] == '\r')) {
                 buf[++bytes] = '\0';
                 break;
               }
-- 
1.7.1




reply via email to

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