[asterisk-dev] [Code Review] 4263: Fix characters unjustly cast to unsigned int before printf formatting

opticron reviewboard at asterisk.org
Mon Dec 15 08:49:39 CST 2014


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviewboard.asterisk.org/r/4263/#review13961
-----------------------------------------------------------

Ship it!


I verified that this compiles properly with gcc 4.10.

- opticron


On Dec. 15, 2014, 8:09 a.m., wdoekes wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviewboard.asterisk.org/r/4263/
> -----------------------------------------------------------
> 
> (Updated Dec. 15, 2014, 8:09 a.m.)
> 
> 
> Review request for Asterisk Developers and kmoore.
> 
> 
> Bugs: ASTERISK-24619
>     https://issues.asterisk.org/jira/browse/ASTERISK-24619
> 
> 
> Repository: Asterisk
> 
> 
> Description
> -------
> 
> r413586 introduced changes (amongst others) like:
> 
>     -			out += sprintf(out, "%%%02X", (unsigned char) *ptr);
>     +			out += sprintf(out, "%%%02X", (unsigned) *ptr);
> 
> But for high-ascii, that results in lots of FF's, for example:
> 
>     printf("%02X\n", (unsigned)("å"[0])); /* "FFFFFFC3" */
> 
> This changeset attempt to rectify those by using the 'hh' modifier:
> 
>     $ man sprintf | grep hh -A4 | head -n4
>        hh     A  following  integer  conversion  corresponds  to a
>               signed char or unsigned char argument, or a  follow‐
>               ing  n  conversion  corresponds  to  a  pointer to a
>               signed char argument.
> 
> I also replaced occurrences of 2.2x with 02x. They appear to be equal.
> 
> 
> This issue was reported by Stefan27 on IRC.
> 
> 
> Diffs
> -----
> 
>   /branches/1.8/utils/astman.c 429562 
>   /branches/1.8/res/res_pktccops.c 429562 
>   /branches/1.8/res/res_crypto.c 429562 
>   /branches/1.8/pbx/dundi-parser.c 429562 
>   /branches/1.8/main/utils.c 429562 
>   /branches/1.8/main/netsock.c 429562 
>   /branches/1.8/main/manager.c 429562 
>   /branches/1.8/main/loader.c 429562 
>   /branches/1.8/channels/sig_pri.c 429562 
>   /branches/1.8/channels/iax2-parser.c 429562 
>   /branches/1.8/channels/chan_sip.c 429562 
>   /branches/1.8/channels/chan_misdn.c 429562 
>   /branches/1.8/channels/chan_iax2.c 429562 
>   /branches/1.8/apps/app_sms.c 429562 
>   /branches/1.8/apps/app_getcpeid.c 429562 
> 
> Diff: https://reviewboard.asterisk.org/r/4263/diff/
> 
> 
> Testing
> -------
> 
> It compiles with gcc 4.8. Did not test with gcc 4.10 which was
> the cause for the r413586 fixes.
> 
> 
> Thanks,
> 
> wdoekes
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20141215/4420d670/attachment.html>


More information about the asterisk-dev mailing list