aboutsummaryrefslogtreecommitdiffstats
path: root/enum.c
diff options
context:
space:
mode:
authormarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2005-03-12 06:56:22 +0000
committermarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2005-03-12 06:56:22 +0000
commite59480f4fe5f681ca2bd810c65455309c9138816 (patch)
tree51d1b96633350a91a9bce40daf3230586c68071c /enum.c
parent8cf288022bfa8c2b0f6137c4cd33f3176a83459e (diff)
Fix TXTCIDName app (bug #3681)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@5175 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'enum.c')
-rwxr-xr-xenum.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/enum.c b/enum.c
index 5d9b4c6fa..8ebc2a441 100755
--- a/enum.c
+++ b/enum.c
@@ -268,9 +268,25 @@ static int txt_callback(void *context, u_char *answer, int len, u_char *fullansw
c->txtlen = 0;
return 0;
}
- strncpy(c->txt, answer, sizeof(c->txt) - 1);
- c->txt[sizeof(c->txt) - 1] = 0; /* Make sure the string is terminated */
- c->txtlen = strlen(c->txt);
+
+ /* 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] = (u_char)"\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] = (char)"\0";
+
return 1;
}