diff options
author | Walter Doekes <walter+asterisk@wjd.nu> | 2014-12-17 09:54:00 +0000 |
---|---|---|
committer | Walter Doekes <walter+asterisk@wjd.nu> | 2014-12-17 09:54:00 +0000 |
commit | 9ae57e0dd6841dad6930a75d7907d32a1efff4d2 (patch) | |
tree | ee131dd37a2383d2be12aab71e5737db4292083a /channels/chan_iax2.c | |
parent | a3534b7c0547db14c87f3f2622786a40374a74ee (diff) |
Fix printf problems with high ascii characters after r413586 (1.8).
In r413586 (1.8) various casts were added to silence gcc 4.10 warnings.
Those fixes included things like:
-out += sprintf(out, "%%%02X", (unsigned char) *ptr);
+out += sprintf(out, "%%%02X", (unsigned) *ptr);
That works for low ascii characters, but for the high range that yields
e.g. FFFFFFC3 when C3 is expected.
This changeset:
- fixes those casts to use the 'hh' unsigned char modifier instead
- consistently uses %02x instead of %2.2x (or other non-standard usage)
- adds a few 'h' modifiers in various places
- fixes a 'replcaes' typo
- dev/urandon typo (in 13+ patch)
Review: https://reviewboard.asterisk.org/r/4263/
ASTERISK-24619 #close
Reported by: Stefan27 (on IRC)
........
Merged revisions 429673 from http://svn.asterisk.org/svn/asterisk/branches/11
........
Merged revisions 429674 from http://svn.asterisk.org/svn/asterisk/branches/12
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/13@429675 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels/chan_iax2.c')
-rw-r--r-- | channels/chan_iax2.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c index 39861db0e..c01bf5c7a 100644 --- a/channels/chan_iax2.c +++ b/channels/chan_iax2.c @@ -387,7 +387,7 @@ static int (*iax2_regfunk)(const char *username, int onoff) = NULL; break; \ \ for (idx = 0; idx < 16; idx++) \ - sprintf(digest + (idx << 1), "%2.2x", (unsigned) key[idx]); \ + sprintf(digest + (idx << 1), "%02hhx", (unsigned char) key[idx]); \ \ ast_log(LOG_NOTICE, msg " IAX_COMMAND_RTKEY to rotate key to '%s'\n", digest); \ } while(0) @@ -6442,7 +6442,7 @@ static int decode_frame(ast_aes_decrypt_key *dcx, struct ast_iax2_full_hdr *fh, padding = 16 + (workspace[15] & 0x0f); if (iaxdebug) - ast_debug(1, "Decoding full frame with length %d (padding = %d) (15=%02x)\n", *datalen, padding, (unsigned)workspace[15]); + ast_debug(1, "Decoding full frame with length %d (padding = %d) (15=%02hhx)\n", *datalen, padding, workspace[15]); if (*datalen < padding + sizeof(struct ast_iax2_full_hdr)) return -1; @@ -6489,7 +6489,7 @@ static int encrypt_frame(ast_aes_encrypt_key *ecx, struct ast_iax2_full_hdr *fh, workspace[15] &= 0xf0; workspace[15] |= (padding & 0xf); if (iaxdebug) - ast_debug(1, "Encoding full frame %d/%d with length %d + %d padding (15=%02x)\n", fh->type, fh->csub, *datalen, padding, (unsigned)workspace[15]); + ast_debug(1, "Encoding full frame %d/%d with length %d + %d padding (15=%02hhx)\n", fh->type, fh->csub, *datalen, padding, workspace[15]); *datalen += padding; memcpy_encrypt(efh->encdata, workspace, *datalen - sizeof(struct ast_iax2_full_enc_hdr), ecx); if (*datalen >= 32 + sizeof(struct ast_iax2_full_enc_hdr)) @@ -8207,7 +8207,7 @@ static int authenticate_verify(struct chan_iax2_pvt *p, struct iax_ies *ies) MD5Final(digest, &md5); /* If they support md5, authenticate with it. */ for (x=0;x<16;x++) - sprintf(requeststr + (x << 1), "%2.2x", (unsigned)digest[x]); /* safe */ + sprintf(requeststr + (x << 1), "%02hhx", digest[x]); /* safe */ if (!strcasecmp(requeststr, md5secret)) { res = 0; break; @@ -8339,7 +8339,7 @@ static int register_verify(int callno, struct ast_sockaddr *addr, struct iax_ies MD5Update(&md5, (unsigned char *)tmppw, strlen(tmppw)); MD5Final(digest, &md5); for (x=0;x<16;x++) - sprintf(requeststr + (x << 1), "%2.2x", (unsigned)digest[x]); /* safe */ + sprintf(requeststr + (x << 1), "%02hhx", digest[x]); /* safe */ if (!strcasecmp(requeststr, md5secret)) break; } @@ -8423,7 +8423,7 @@ static int authenticate(const char *challenge, const char *secret, const char *k MD5Final(digest, &md5); /* If they support md5, authenticate with it. */ for (x=0;x<16;x++) - sprintf(digres + (x << 1), "%2.2x", (unsigned)digest[x]); /* safe */ + sprintf(digres + (x << 1), "%02hhx", digest[x]); /* safe */ if (pvt) { build_encryption_keys(digest, pvt); } |