[sr-dev] git:master: modules_k/usrloc If path is Null, prevent memcpy on it in get_all_ucontact(mode DB_ONLY)

Marius Zbihlei marius.zbihlei at 1and1.ro
Fri Jan 14 17:04:47 CET 2011


Module: sip-router
Branch: master
Commit: 5b2881b694510bcca94d1bfbf9c08ea49478b989
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=5b2881b694510bcca94d1bfbf9c08ea49478b989

Author: Marius Zbihlei <marius.zbihlei at 1and1.ro>
Committer: Marius Zbihlei <marius.zbihlei at 1and1.ro>
Date:   Fri Jan 14 17:47:32 2011 +0200

modules_k/usrloc If path is Null, prevent memcpy on it in get_all_ucontact(mode DB_ONLY)

---

 modules_k/usrloc/dlist.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/modules_k/usrloc/dlist.c b/modules_k/usrloc/dlist.c
index 8c739d4..6399fad 100644
--- a/modules_k/usrloc/dlist.c
+++ b/modules_k/usrloc/dlist.c
@@ -223,8 +223,11 @@ static inline int get_all_db_ucontacts(void *buf, int len, unsigned int flags,
 			/* write path */
 			memcpy(cp, &p1_len, sizeof(p1_len));
 			cp = (char*)cp + sizeof(p1_len);
-			memcpy(cp, p1, p1_len);
-			cp = (char*)cp + p1_len;
+			/* copy path only if exist */
+			if(p1_len){
+				memcpy(cp, p1, p1_len);
+				cp = (char*)cp + p1_len;
+			}
 
 			len -= needed;
 		} /* row cycle */




More information about the sr-dev mailing list