[tor-commits] [vidalia/alpha] Add another check for the control reply parsing

chiiph at torproject.org chiiph at torproject.org
Thu Jun 14 22:42:08 UTC 2012


commit d5392a787b6eff16629a360029879523e95c50ef
Author: Tomás Touceda <chiiph at torproject.org>
Date:   Wed Jun 13 11:50:24 2012 -0300

    Add another check for the control reply parsing
---
 src/torcontrol/ControlSocket.cpp |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/src/torcontrol/ControlSocket.cpp b/src/torcontrol/ControlSocket.cpp
index fd5f31e..69dd2d8 100644
--- a/src/torcontrol/ControlSocket.cpp
+++ b/src/torcontrol/ControlSocket.cpp
@@ -283,7 +283,14 @@ ControlSocket::readReply(ControlReply &reply, QString *errmsg)
     }
 
     /* Parse the status and message */
-    ReplyLine replyLine(line.mid(0, 3), line.mid(4));
+    QString status = line.mid(0,3);
+    bool ok = false;
+    status.toInt(&ok);
+    if (!ok) {
+      return err(errmsg, QString("Malformed control reply: %1").arg(line));
+    }
+
+    ReplyLine replyLine(status, line.mid(4));
     c = line.at(3);
 
     /* If the reply line contains data, then parse out the data up until the





More information about the tor-commits mailing list