don't use a signed buffer for data that the protocol specifies as unsigned.
authorRussell Bryant <russell@russellbryant.com>
Fri, 9 Sep 2005 01:07:25 +0000 (01:07 +0000)
committerRussell Bryant <russell@russellbryant.com>
Fri, 9 Sep 2005 01:07:25 +0000 (01:07 +0000)
This fixes an issues with RSA authentication (issue #5148)

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6554 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_iax2.c
channels/iax2-parser.c
channels/iax2-parser.h

index 0ea0196..1649d66 100755 (executable)
@@ -6132,7 +6132,7 @@ static int socket_read(int *id, int fd, short events, void *cbdata)
        int res;
        int updatehistory=1;
        int new = NEW_PREVENT;
-       char buf[4096]; 
+       unsigned char buf[4096]; 
        void *ptr;
        socklen_t len = sizeof(sin);
        int dcallno = 0;
index 17f7c56..71dcd36 100755 (executable)
@@ -573,7 +573,7 @@ void iax_set_error(void (*func)(const char *))
        errorf = func;
 }
 
-int iax_parse_ies(struct iax_ies *ies, char *data, int datalen)
+int iax_parse_ies(struct iax_ies *ies, unsigned char *data, int datalen)
 {
        /* Parse data into information elements */
        int len;
@@ -595,28 +595,28 @@ int iax_parse_ies(struct iax_ies *ies, char *data, int datalen)
                }
                switch(ie) {
                case IAX_IE_CALLED_NUMBER:
-                       ies->called_number = data + 2;
+                       ies->called_number = (char *)data + 2;
                        break;
                case IAX_IE_CALLING_NUMBER:
-                       ies->calling_number = data + 2;
+                       ies->calling_number = (char *)data + 2;
                        break;
                case IAX_IE_CALLING_ANI:
-                       ies->calling_ani = data + 2;
+                       ies->calling_ani = (char *)data + 2;
                        break;
                case IAX_IE_CALLING_NAME:
-                       ies->calling_name = data + 2;
+                       ies->calling_name = (char *)data + 2;
                        break;
                case IAX_IE_CALLED_CONTEXT:
-                       ies->called_context = data + 2;
+                       ies->called_context = (char *)data + 2;
                        break;
                case IAX_IE_USERNAME:
-                       ies->username = data + 2;
+                       ies->username = (char *)data + 2;
                        break;
                case IAX_IE_PASSWORD:
-                       ies->password = data + 2;
+                       ies->password = (char *)data + 2;
                        break;
                case IAX_IE_CODEC_PREFS:
-                       ies->codec_prefs = data + 2;
+                       ies->codec_prefs = (char *)data + 2;
                        break;
                case IAX_IE_CAPABILITY:
                        if (len != (int)sizeof(unsigned int)) {
@@ -633,7 +633,7 @@ int iax_parse_ies(struct iax_ies *ies, char *data, int datalen)
                                ies->format = ntohl(get_unaligned_uint32(data + 2));
                        break;
                case IAX_IE_LANGUAGE:
-                       ies->language = data + 2;
+                       ies->language = (char *)data + 2;
                        break;
                case IAX_IE_VERSION:
                        if (len != (int)sizeof(unsigned short)) {
@@ -657,10 +657,10 @@ int iax_parse_ies(struct iax_ies *ies, char *data, int datalen)
                                ies->samprate = ntohs(get_unaligned_uint16(data + 2));
                        break;
                case IAX_IE_DNID:
-                       ies->dnid = data + 2;
+                       ies->dnid = (char *)data + 2;
                        break;
                case IAX_IE_RDNIS:
-                       ies->rdnis = data + 2;
+                       ies->rdnis = (char *)data + 2;
                        break;
                case IAX_IE_AUTHMETHODS:
                        if (len != (int)sizeof(unsigned short))  {
@@ -677,13 +677,13 @@ int iax_parse_ies(struct iax_ies *ies, char *data, int datalen)
                                ies->encmethods = ntohs(get_unaligned_uint16(data + 2));
                        break;
                case IAX_IE_CHALLENGE:
-                       ies->challenge = data + 2;
+                       ies->challenge = (char *)data + 2;
                        break;
                case IAX_IE_MD5_RESULT:
-                       ies->md5_result = data + 2;
+                       ies->md5_result = (char *)data + 2;
                        break;
                case IAX_IE_RSA_RESULT:
-                       ies->rsa_result = data + 2;
+                       ies->rsa_result = (char *)data + 2;
                        break;
                case IAX_IE_APPARENT_ADDR:
                        ies->apparent_addr = ((struct sockaddr_in *)(data + 2));
@@ -710,7 +710,7 @@ int iax_parse_ies(struct iax_ies *ies, char *data, int datalen)
                                ies->callno = ntohs(get_unaligned_uint16(data + 2));
                        break;
                case IAX_IE_CAUSE:
-                       ies->cause = data + 2;
+                       ies->cause = (char *)data + 2;
                        break;
                case IAX_IE_CAUSECODE:
                        if (len != 1) {
@@ -763,10 +763,10 @@ int iax_parse_ies(struct iax_ies *ies, char *data, int datalen)
                                ies->firmwarever = ntohs(get_unaligned_uint16(data + 2));       
                        break;
                case IAX_IE_DEVICETYPE:
-                       ies->devicetype = data + 2;
+                       ies->devicetype = (char *)data + 2;
                        break;
                case IAX_IE_SERVICEIDENT:
-                       ies->serviceident = data + 2;
+                       ies->serviceident = (char *)data + 2;
                        break;
                case IAX_IE_FWBLOCKDESC:
                        if (len != (int)sizeof(unsigned int)) {
@@ -776,11 +776,11 @@ int iax_parse_ies(struct iax_ies *ies, char *data, int datalen)
                                ies->fwdesc = ntohl(get_unaligned_uint32(data + 2));
                        break;
                case IAX_IE_FWBLOCKDATA:
-                       ies->fwdata = (unsigned char *)data + 2;
+                       ies->fwdata = data + 2;
                        ies->fwdatalen = len;
                        break;
                case IAX_IE_ENCKEY:
-                       ies->enckey = (unsigned char *)data + 2;
+                       ies->enckey = data + 2;
                        ies->enckeylen = len;
                        break;
                case IAX_IE_PROVVER:
index f8a940d..1ed8956 100755 (executable)
@@ -139,7 +139,7 @@ extern int iax_ie_append_short(struct iax_ie_data *ied, unsigned char ie, unsign
 extern int iax_ie_append_str(struct iax_ie_data *ied, unsigned char ie, char *str);
 extern int iax_ie_append_byte(struct iax_ie_data *ied, unsigned char ie, unsigned char dat);
 extern int iax_ie_append(struct iax_ie_data *ied, unsigned char ie);
-extern int iax_parse_ies(struct iax_ies *ies, char *data, int datalen);
+extern int iax_parse_ies(struct iax_ies *ies, unsigned char *data, int datalen);
 
 extern int iax_get_frames(void);
 extern int iax_get_iframes(void);