[asterisk-commits] file: trunk r41280 - /trunk/channels/chan_iax2.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Tue Aug 29 13:53:28 MST 2006


Author: file
Date: Tue Aug 29 15:53:27 2006
New Revision: 41280

URL: http://svn.digium.com/view/asterisk?rev=41280&view=rev
Log:
Limit challenges to 9 digits in length

Modified:
    trunk/channels/chan_iax2.c

Modified: trunk/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_iax2.c?rev=41280&r1=41279&r2=41280&view=diff
==============================================================================
--- trunk/channels/chan_iax2.c (original)
+++ trunk/channels/chan_iax2.c Tue Aug 29 15:53:27 2006
@@ -4787,6 +4787,7 @@
 	struct iax2_user *user = NULL;
 	struct iax_ie_data ied;
 	int res = -1, authreq_restrict = 0;
+	char challenge[10];
 
 	memset(&ied, 0, sizeof(ied));
 
@@ -4815,7 +4816,8 @@
 
 	iax_ie_append_short(&ied, IAX_IE_AUTHMETHODS, p->authmethods);
 	if (p->authmethods & (IAX_AUTH_MD5 | IAX_AUTH_RSA)) {
-		ast_string_field_build(p,challenge, "%d", (int)ast_random());
+		snprintf(challenge, sizeof(challenge), "%d", (int)ast_random());
+		ast_string_field_set(p, challenge, challenge);
 		/* snprintf(p->challenge, sizeof(p->challenge), "%d", (int)ast_random()); */
 		iax_ie_append_str(&ied, IAX_IE_CHALLENGE, p->challenge);
 	}
@@ -5644,6 +5646,7 @@
 {
 	struct iax_ie_data ied;
 	struct iax2_peer *p;
+	char challenge[10];
 	/* SLD: third call to find_peer in registration */
 	p = find_peer(name, 1);
 	if (p) {
@@ -5651,7 +5654,8 @@
 		iax_ie_append_short(&ied, IAX_IE_AUTHMETHODS, p->authmethods);
 		if (p->authmethods & (IAX_AUTH_RSA | IAX_AUTH_MD5)) {
 			/* Build the challenge */
-			ast_string_field_build(iaxs[callno], challenge, "%d", (int)ast_random());
+			snprintf(challenge, sizeof(challenge), "%d", (int)ast_random());
+			ast_string_field_set(iaxs[callno], challenge, challenge);
 			/* snprintf(iaxs[callno]->challenge, sizeof(iaxs[callno]->challenge), "%d", (int)ast_random()); */
 			iax_ie_append_str(&ied, IAX_IE_CHALLENGE, iaxs[callno]->challenge);
 		}



More information about the asterisk-commits mailing list