]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
fix TXTCIDName (bug #3681)
authorRussell Bryant <russell@russellbryant.com>
Thu, 17 Mar 2005 00:19:23 +0000 (00:19 +0000)
committerRussell Bryant <russell@russellbryant.com>
Thu, 17 Mar 2005 00:19:23 +0000 (00:19 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/v1-0@5184 65c4cc65-6c06-0410-ace0-fbb531ad65f3

enum.c

diff --git a/enum.c b/enum.c
index 690587163a8cb5e252176ef06d21ddc058f76273..6e26836704018be2cfe2c920026ab17b2487fd6d 100755 (executable)
--- a/enum.c
+++ b/enum.c
@@ -244,16 +244,31 @@ static int txt_callback(void *context, u_char *answer, int len, u_char *fullansw
        printf("ENUMTXT Called\n");
 #endif
 
-       if (answer != NULL) {
-               c->txtlen = strlen(answer);
-               strncpy(c->txt, answer, sizeof(c->txt) - 1);
-               c->txt[sizeof(c->txt) - 1] = 0;
-               return 1;
-       } else {
+       if (answer == NULL) {
                c->txt = NULL;
                c->txtlen = 0;
                return 0;
        }
+
+       /* skip over first byte, as for some reason it's a vertical tab character */
+       answer += 1;
+       len -= 1;
+
+       /* answer is not null-terminated, but should be */
+       /* this is safe to do, as answer has extra bytes on the end we can 
+           safely overwrite with a null */
+       answer[len] = '\0';
+       /* now increment len so that len includes the null, so that we can
+          compare apples to apples */
+       len +=1;
+
+       /* finally, copy the answer into c->txt */
+       strncpy(c->txt, answer, len < c->txtlen ? len-1 : (c->txtlen)-1);
+       
+       /* just to be safe, let's make sure c->txt is null terminated */
+       c->txt[(c->txtlen)-1] = '\0';
+
+       return 1;
 }
 
 static int enum_callback(void *context, u_char *answer, int len, u_char *fullanswer)