[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

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



commit d5392a787b6eff16629a360029879523e95c50ef
Author: Tomás Touceda <chiiph@xxxxxxxxxxxxxx>
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



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits