You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bugs@apr.apache.org by bu...@apache.org on 2007/04/25 17:42:55 UTC
DO NOT REPLY [Bug 42250] New: - apr_snprintf %llu conversion for uint64_t can fail for large numbers
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=42250>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=42250
Summary: apr_snprintf %llu conversion for uint64_t can fail for
large numbers
Product: APR
Version: HEAD
Platform: All
OS/Version: Linux
Status: NEW
Severity: major
Priority: P1
Component: APR
AssignedTo: bugs@apr.apache.org
ReportedBy: wynn@bungeelabs.com
If apr_snprintf is called with a format of %llu and a uint64_t is passed in,
the code in conv_10_quad() in strings/apr_snprintf.c that tries to optimize
the conversion by downcasting to a 32 bit number will sometimes incorrectly
determine that the number can be treated as a 32 bit number.
If the original uint64_t number is large enough (like 10267677267010969076 -
becomes -8179066806698582540 when cast to an int64_t) that it becomes negative
when casted to the type that the widest_int type def is (int64_t in this
case), the line (#399 in 1.2.8 - should be about the same place in
subversion):
if ((num <= ULONG_MAX && is_unsigned)
will incorrectly succeed since the int64_t version (-8179066806698582540) is
less than ULONG_MAX. Changing the line to:
if (((u_widest_int)num <= (u_widest_int)ULONG_MAX && is_unsigned)
fixes the problem as then num is not treated as a negative compiler. This may
be compiler-dependant (i've seen this on kubuntu 7.04 with gcc 4.1.2) but it
would be better to make the behavior explicit with the u_widest_int cast.
--
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@apr.apache.org
For additional commands, e-mail: bugs-help@apr.apache.org
DO NOT REPLY [Bug 42250] - apr_snprintf %llu conversion for uint64_t can fail for large numbers
Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=42250>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=42250
------- Additional Comments From davi@haxent.com.br 2007-04-26 07:13 -------
Created an attachment (id=20051)
--> (http://issues.apache.org/bugzilla/attachment.cgi?id=20051&action=view)
Convert early
--
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@apr.apache.org
For additional commands, e-mail: bugs-help@apr.apache.org
DO NOT REPLY [Bug 42250] - apr_snprintf %llu conversion for uint64_t can fail for large numbers
Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=42250>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=42250
------- Additional Comments From wrowe@apache.org 2007-04-26 02:35 -------
u_widest_int - yuck - horribly nonportable.
Wouldn't apr_int32_t accomplish the same (and solve the portability issues)?
--
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@apr.apache.org
For additional commands, e-mail: bugs-help@apr.apache.org
DO NOT REPLY [Bug 42250] - apr_snprintf %llu conversion for uint64_t can fail for large numbers
Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=42250>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=42250
davi@haxent.com.br changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |REOPENED
Resolution|FIXED |
------- Additional Comments From davi@haxent.com.br 2007-04-26 07:10 -------
Ummm, the code can be much simpler and faster. Patches will follow.
--
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@apr.apache.org
For additional commands, e-mail: bugs-help@apr.apache.org
DO NOT REPLY [Bug 42250] - apr_snprintf %llu conversion for uint64_t can fail for large numbers
Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=42250>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=42250
------- Additional Comments From davi@haxent.com.br 2007-04-26 07:14 -------
Created an attachment (id=20052)
--> (http://issues.apache.org/bugzilla/attachment.cgi?id=20052&action=view)
The classic approach is way faster
--
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@apr.apache.org
For additional commands, e-mail: bugs-help@apr.apache.org
Re: DO NOT REPLY [Bug 42250] - apr_snprintf %llu conversion for
uint64_t can fail for large numbers
Posted by "William A. Rowe, Jr." <wr...@rowe-clan.net>.
http://issues.apache.org/bugzilla/show_bug.cgi?id=42250
hth? I'm not quite sure how this got committed without feedback to my
question... Joe? Is my concern unfounded? Or should this be reverted?
------- Additional Comments From wrowe@apache.org 2007-04-26 02:35 -------
u_widest_int - yuck - horribly nonportable.
Wouldn't apr_int32_t accomplish the same (and solve the portability issues)?
------- Additional Comments From jorton@redhat.com 2007-04-26 06:20 -------
Thanks for the fix! http://svn.apache.org/viewvc?view=rev&revision=532733 and
http://svn.apache.org/viewvc?view=rev&rev=532735
DO NOT REPLY [Bug 42250] - apr_snprintf %llu conversion for uint64_t can fail for large numbers
Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=42250>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=42250
jorton@redhat.com changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
------- Additional Comments From jorton@redhat.com 2007-04-26 06:20 -------
Thanks for the fix! http://svn.apache.org/viewvc?view=rev&revision=532733 and
http://svn.apache.org/viewvc?view=rev&rev=532735
--
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@apr.apache.org
For additional commands, e-mail: bugs-help@apr.apache.org
DO NOT REPLY [Bug 42250] - apr_snprintf %llu conversion for uint64_t can fail for large numbers
Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=42250>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=42250
jorton@redhat.com changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|REOPENED |RESOLVED
Resolution| |FIXED
------- Additional Comments From jorton@redhat.com 2007-04-26 08:58 -------
The fact that the code could be "simpler and faster" (which I don't doubt) is
not the issue reported here; can you send your cleanup to dev@apr?
--
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@apr.apache.org
For additional commands, e-mail: bugs-help@apr.apache.org
DO NOT REPLY [Bug 42250] - apr_snprintf %llu conversion for uint64_t can fail for large numbers
Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=42250>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=42250
------- Additional Comments From wynn@bungeelabs.com 2007-04-26 08:10 -------
I tested Davi's patches and they worked fine for me. Thanks for the prompt
attention to this.
--
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@apr.apache.org
For additional commands, e-mail: bugs-help@apr.apache.org