use native-sign characters for strings (issue #5105)
authorKevin P. Fleming <kpfleming@digium.com>
Fri, 2 Sep 2005 19:15:03 +0000 (19:15 +0000)
committerKevin P. Fleming <kpfleming@digium.com>
Fri, 2 Sep 2005 19:15:03 +0000 (19:15 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6507 65c4cc65-6c06-0410-ace0-fbb531ad65f3

pbx/dundi-parser.c
pbx/dundi-parser.h
pbx/pbx_dundi.c

index b29224d..18d656b 100755 (executable)
@@ -507,7 +507,7 @@ int dundi_ie_append_raw(struct dundi_ie_data *ied, unsigned char ie, void *data,
        return 0;
 }
 
-int dundi_ie_append_cause(struct dundi_ie_data *ied, unsigned char ie, unsigned char cause, unsigned char *data)
+int dundi_ie_append_cause(struct dundi_ie_data *ied, unsigned char ie, unsigned char cause, char *data)
 {
        char tmp[256];
        int datalen = data ? strlen(data) + 1 : 1;
@@ -524,7 +524,7 @@ int dundi_ie_append_cause(struct dundi_ie_data *ied, unsigned char ie, unsigned
        return 0;
 }
 
-int dundi_ie_append_hint(struct dundi_ie_data *ied, unsigned char ie, unsigned short flags, unsigned char *data)
+int dundi_ie_append_hint(struct dundi_ie_data *ied, unsigned char ie, unsigned short flags, char *data)
 {
        char tmp[256];
        int datalen = data ? strlen(data) + 2 : 2;
@@ -563,7 +563,7 @@ int dundi_ie_append_encdata(struct dundi_ie_data *ied, unsigned char ie, unsigne
        return 0;
 }
 
-int dundi_ie_append_answer(struct dundi_ie_data *ied, unsigned char ie, dundi_eid *eid, unsigned char protocol, unsigned short flags, unsigned short weight, unsigned char *data)
+int dundi_ie_append_answer(struct dundi_ie_data *ied, unsigned char ie, dundi_eid *eid, unsigned char protocol, unsigned short flags, unsigned short weight, char *data)
 {
        char tmp[256];
        int datalen = data ? strlen(data) + 11 : 11;
@@ -609,7 +609,7 @@ int dundi_ie_append_short(struct dundi_ie_data *ied, unsigned char ie, unsigned
        return dundi_ie_append_raw(ied, ie, &newval, (int)sizeof(newval));
 }
 
-int dundi_ie_append_str(struct dundi_ie_data *ied, unsigned char ie, unsigned char *str)
+int dundi_ie_append_str(struct dundi_ie_data *ied, unsigned char ie, char *str)
 {
        return dundi_ie_append_raw(ied, ie, str, strlen(str));
 }
@@ -676,10 +676,10 @@ int dundi_parse_ies(struct dundi_ies *ies, unsigned char *data, int datalen)
                                ies->reqeid = (dundi_eid *)(data + 2);
                        break;
                case DUNDI_IE_CALLED_CONTEXT:
-                       ies->called_context = data + 2;
+                       ies->called_context = (char *)data + 2;
                        break;
                case DUNDI_IE_CALLED_NUMBER:
-                       ies->called_number = data + 2;
+                       ies->called_number = (char *)data + 2;
                        break;
                case DUNDI_IE_ANSWER:
                        if (len < sizeof(struct dundi_answer)) {
@@ -731,7 +731,7 @@ int dundi_parse_ies(struct dundi_ies *ies, unsigned char *data, int datalen)
                case DUNDI_IE_CAUSE:
                        if (len >= 1) {
                                ies->cause = data[2];
-                               ies->causestr = data + 3;
+                               ies->causestr = (char *)data + 3;
                        } else {
                                snprintf(tmp, (int)sizeof(tmp), "Expected at least one byte cause, but was %d long\n", len);
                                errorf(tmp);
@@ -746,28 +746,28 @@ int dundi_parse_ies(struct dundi_ies *ies, unsigned char *data, int datalen)
                        }
                        break;
                case DUNDI_IE_DEPARTMENT:
-                       ies->q_dept = data + 2;
+                       ies->q_dept = (char *)data + 2;
                        break;
                case DUNDI_IE_ORGANIZATION:
-                       ies->q_org = data + 2;
+                       ies->q_org = (char *)data + 2;
                        break;
                case DUNDI_IE_LOCALITY:
-                       ies->q_locality = data + 2;
+                       ies->q_locality = (char *)data + 2;
                        break;
                case DUNDI_IE_STATE_PROV:
-                       ies->q_stateprov = data + 2;
+                       ies->q_stateprov = (char *)data + 2;
                        break;
                case DUNDI_IE_COUNTRY:
-                       ies->q_country = data + 2;
+                       ies->q_country = (char *)data + 2;
                        break;
                case DUNDI_IE_EMAIL:
-                       ies->q_email = data + 2;
+                       ies->q_email = (char *)data + 2;
                        break;
                case DUNDI_IE_PHONE:
-                       ies->q_phone = data + 2;
+                       ies->q_phone = (char *)data + 2;
                        break;
                case DUNDI_IE_IPADDR:
-                       ies->q_ipaddr = data + 2;
+                       ies->q_ipaddr = (char *)data + 2;
                        break;
                case DUNDI_IE_ENCDATA:
                        /* Recalculate len as the remainder of the message, regardless of
index 3ea701e..62bbf43 100755 (executable)
@@ -34,15 +34,15 @@ struct dundi_ies {
        int unknowncmd;
        unsigned char *pubkey;
        int cause;
-       unsigned char *q_dept;
-       unsigned char *q_org;
-       unsigned char *q_locality;
-       unsigned char *q_stateprov;
-       unsigned char *q_country;
-       unsigned char *q_email;
-       unsigned char *q_phone;
-       unsigned char *q_ipaddr;
-       unsigned char *causestr;
+       char *q_dept;
+       char *q_org;
+       char *q_locality;
+       char *q_stateprov;
+       char *q_country;
+       char *q_email;
+       char *q_phone;
+       char *q_ipaddr;
+       char *causestr;
        unsigned char *encsharedkey;
        unsigned char *encsig;
        unsigned long keycrc32;
@@ -68,11 +68,11 @@ extern int dundi_ie_append_raw(struct dundi_ie_data *ied, unsigned char ie, void
 extern int dundi_ie_append_addr(struct dundi_ie_data *ied, unsigned char ie, struct sockaddr_in *sin);
 extern int dundi_ie_append_int(struct dundi_ie_data *ied, unsigned char ie, unsigned int value);
 extern int dundi_ie_append_short(struct dundi_ie_data *ied, unsigned char ie, unsigned short value);
-extern int dundi_ie_append_str(struct dundi_ie_data *ied, unsigned char ie, unsigned char *str);
+extern int dundi_ie_append_str(struct dundi_ie_data *ied, unsigned char ie, char *str);
 extern int dundi_ie_append_eid(struct dundi_ie_data *ied, unsigned char ie, dundi_eid *eid);
-extern int dundi_ie_append_cause(struct dundi_ie_data *ied, unsigned char ie, unsigned char cause, unsigned char *desc);
-extern int dundi_ie_append_hint(struct dundi_ie_data *ied, unsigned char ie, unsigned short flags, unsigned char *data);
-extern int dundi_ie_append_answer(struct dundi_ie_data *ied, unsigned char ie, dundi_eid *eid, unsigned char protocol, unsigned short flags, unsigned short weight, unsigned char *desc);
+extern int dundi_ie_append_cause(struct dundi_ie_data *ied, unsigned char ie, unsigned char cause, char *desc);
+extern int dundi_ie_append_hint(struct dundi_ie_data *ied, unsigned char ie, unsigned short flags, char *data);
+extern int dundi_ie_append_answer(struct dundi_ie_data *ied, unsigned char ie, dundi_eid *eid, unsigned char protocol, unsigned short flags, unsigned short weight, char *desc);
 extern int dundi_ie_append_encdata(struct dundi_ie_data *ied, unsigned char ie, unsigned char *iv, void *data, int datalen);
 extern int dundi_ie_append_byte(struct dundi_ie_data *ied, unsigned char ie, unsigned char dat);
 extern int dundi_ie_append(struct dundi_ie_data *ied, unsigned char ie);
index 6122f42..02efc40 100755 (executable)
@@ -909,7 +909,7 @@ static int dundi_prop_precache(struct dundi_transaction *trans, struct dundi_ies
                        /* Make sure it's not already there */
                        for (z=0;z<trans->parent->respcount;z++) {
                                if ((trans->parent->dr[z].techint == ies->answers[x]->protocol) &&
-                                   !strcmp(trans->parent->dr[z].dest, ies->answers[x]->data)) 
+                                   !strcmp(trans->parent->dr[z].dest, (char *)ies->answers[x]->data)) 
                                                break;
                        }
                        if (z == trans->parent->respcount) {
@@ -925,7 +925,7 @@ static int dundi_prop_precache(struct dundi_transaction *trans, struct dundi_ies
                                dundi_eid_to_str(trans->parent->dr[trans->parent->respcount].eid_str, 
                                        sizeof(trans->parent->dr[trans->parent->respcount].eid_str),
                                        &ies->answers[x]->eid);
-                               strncpy(trans->parent->dr[trans->parent->respcount].dest, ies->answers[x]->data,
+                               strncpy(trans->parent->dr[trans->parent->respcount].dest, (char *)ies->answers[x]->data,
                                        sizeof(trans->parent->dr[trans->parent->respcount].dest));
                                        strncpy(trans->parent->dr[trans->parent->respcount].tech, tech2str(ies->answers[x]->protocol),
                                        sizeof(trans->parent->dr[trans->parent->respcount].tech));
@@ -1304,7 +1304,7 @@ static int update_key(struct dundi_peer *peer)
                        ast_log(LOG_NOTICE, "Whoa, got a weird encrypt size (%d != %d)!\n", res, 128);
                        return -1;
                }
-               if ((res = ast_sign_bin(skey, peer->txenckey, 128, peer->txenckey + 128))) {
+               if ((res = ast_sign_bin(skey, (char *)peer->txenckey, 128, peer->txenckey + 128))) {
                        ast_log(LOG_NOTICE, "Failed to sign key (%d)!\n", res);
                        return -1;
                }
@@ -1475,7 +1475,7 @@ static int check_key(struct dundi_peer *peer, unsigned char *newkey, unsigned ch
        }
 
        /* First check signature */
-       res = ast_check_signature_bin(skey, newkey, 128, newsig);
+       res = ast_check_signature_bin(skey, (char *)newkey, 128, newsig);
        if (res) 
                return 0;
 
@@ -1644,7 +1644,7 @@ static int handle_command_response(struct dundi_transaction *trans, struct dundi
                                                        /* Make sure it's not already there */
                                                        for (z=0;z<trans->parent->respcount;z++) {
                                                                if ((trans->parent->dr[z].techint == ies.answers[x]->protocol) &&
-                                                                   !strcmp(trans->parent->dr[z].dest, ies.answers[x]->data)) 
+                                                                   !strcmp(trans->parent->dr[z].dest, (char *)ies.answers[x]->data)) 
                                                                                break;
                                                        }
                                                        if (z == trans->parent->respcount) {
@@ -1660,7 +1660,7 @@ static int handle_command_response(struct dundi_transaction *trans, struct dundi
                                                                dundi_eid_to_str(trans->parent->dr[trans->parent->respcount].eid_str, 
                                                                        sizeof(trans->parent->dr[trans->parent->respcount].eid_str),
                                                                        &ies.answers[x]->eid);
-                                                               strncpy(trans->parent->dr[trans->parent->respcount].dest, ies.answers[x]->data,
+                                                               strncpy(trans->parent->dr[trans->parent->respcount].dest, (char *)ies.answers[x]->data,
                                                                        sizeof(trans->parent->dr[trans->parent->respcount].dest));
                                                                strncpy(trans->parent->dr[trans->parent->respcount].tech, tech2str(ies.answers[x]->protocol),
                                                                        sizeof(trans->parent->dr[trans->parent->respcount].tech));
@@ -1683,8 +1683,8 @@ static int handle_command_response(struct dundi_transaction *trans, struct dundi
                                                if (ast_test_flag_nonstd(ies.hint, htons(DUNDI_HINT_TTL_EXPIRED)))
                                                        ast_set_flag_nonstd(trans->parent->hmd, DUNDI_HINT_TTL_EXPIRED);
                                                if (ast_test_flag_nonstd(ies.hint, htons(DUNDI_HINT_DONT_ASK))) { 
-                                                       if (strlen(ies.hint->data) > strlen(trans->parent->hmd->exten)) {
-                                                               strncpy(trans->parent->hmd->exten, ies.hint->data, 
+                                                       if (strlen((char *)ies.hint->data) > strlen(trans->parent->hmd->exten)) {
+                                                               strncpy(trans->parent->hmd->exten, (char *)ies.hint->data, 
                                                                        sizeof(trans->parent->hmd->exten) - 1);
                                                        }
                                                } else {
@@ -1969,8 +1969,8 @@ static int socket_read(int *id, int fd, short events, void *cbdata)
        struct sockaddr_in sin;
        int res;
        struct dundi_hdr *h;
-       unsigned char buf[MAX_PACKET_SIZE];
-       int len;
+       char buf[MAX_PACKET_SIZE];
+       socklen_t len;
        len = sizeof(sin);
        res = recvfrom(netsocket, buf, sizeof(buf) - 1, 0,(struct sockaddr *) &sin, &len);
        if (res < 0) {
@@ -1994,11 +1994,11 @@ static int socket_read(int *id, int fd, short events, void *cbdata)
 
 static void build_secret(char *secret, int seclen)
 {
-       char tmp[16];
+       unsigned char tmp[16];
        char *s;
        build_iv(tmp);
        secret[0] = '\0';
-       ast_base64encode(secret ,tmp, sizeof(tmp), seclen);
+       ast_base64encode(secret, tmp, sizeof(tmp), seclen);
        /* Eliminate potential bad characters */
        while((s = strchr(secret, ';'))) *s = '+';
        while((s = strchr(secret, '/'))) *s = '+';