From f20261ba72a43b7e37241802dec24da11901aafa Mon Sep 17 00:00:00 2001
From: yanmorin <yanmorin>
Date: Fri, 30 Sep 2005 21:16:02 +0000
Subject: [PATCH] Bad hack for incoming call...

---
 src/gui/official/sflphone.pro     |  2 +-
 src/gui/server/requestfactory.cpp |  2 +-
 src/sipvoiplink.cpp               | 16 ++++++++++++++++
 3 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/src/gui/official/sflphone.pro b/src/gui/official/sflphone.pro
index 012fccd72f..9d14b58100 100644
--- a/src/gui/official/sflphone.pro
+++ b/src/gui/official/sflphone.pro
@@ -5,7 +5,7 @@
 TEMPLATE = app
 TARGET += 
 DEPENDPATH += .
-INCLUDEPATH += .
+INCLUDEPATH +=  /usr/lib/qt4/include/Qt/
 QT += network
 #CONFIG += debug 
 
diff --git a/src/gui/server/requestfactory.cpp b/src/gui/server/requestfactory.cpp
index 51d0954ea7..56c4440012 100644
--- a/src/gui/server/requestfactory.cpp
+++ b/src/gui/server/requestfactory.cpp
@@ -37,7 +37,7 @@ RequestFactory::create(const std::string& requestLine)
     iter = tList.begin();
 
     // there is atleast a second token (the sequenceId)
-    if (iter != tList.end() && iter->find("seq") == 0 ) {
+    if (iter != tList.end() && iter->size() != 0 ) {
       std::string sequenceId = *iter;
       tList.pop_front();
       try {
diff --git a/src/sipvoiplink.cpp b/src/sipvoiplink.cpp
index 7a14441ba0..ae081999aa 100644
--- a/src/sipvoiplink.cpp
+++ b/src/sipvoiplink.cpp
@@ -556,6 +556,22 @@ SipVoIPLink::getEvent (void)
   switch (event->type) {
     // IP-Phone user receives a new call
   case EXOSIP_CALL_INVITE: //
+    // TODO: remove this hack, when there is no 
+    // buffer overflow in event->request->bodies->body...
+    if (event->request!=NULL && event->request->bodies!=NULL) {
+      if (!osip_list_eol (event->request->bodies, 0)) {
+        osip_body_t* t = (osip_body_t *)osip_list_get (event->request->bodies, 0);
+        if (t!=NULL && t->body!=NULL) {
+          char *lastnewline = strrchr(t->body, '\n');
+          if (lastnewline != NULL ) {
+            lastnewline++;
+            if (*lastnewline != '\0') { 
+              _debug("EXOSIP_CALL_INVITE: request error patched\n"); }
+            *lastnewline = '\0';
+          }
+        }
+      }
+    }
     // Set local random port for incoming call
     if (!Manager::instance().useStun()) {
       setLocalPort(RANDOM_LOCAL_PORT);
-- 
GitLab