[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: %lld in svn_string.c

From: Hyrum K Wright <hyrum_at_hyrumwright.org>
Date: Mon, 9 May 2011 11:02:20 -0500

On Sat, May 7, 2011 at 6:27 AM, Daniel Shahaf <danielsh_at_elego.de> wrote:
> Someone added %lld and %llu codes to svn_string.c:
>
>    return svn_error_return(
>             svn_error_createf(SVN_ERR_INCORRECT_PARAMS, NULL,
>                               _("Number '%s' is out of range '[%lld, %lld]'"),
>                               str, minval, maxval));
>
> So, there are two problems here:
>
> * the svn_error_return() isn't needed around svn_error_createf()
>  (in fact this file/line appears *three* times in the error stack, not
>  just two; but that's another story)
>
> * apr_vformatter() doesn't support the 'll' modifier.  When given %l
>  followed by something other than 'd' or 'u' (for %ld or %lu, etc) ---
>  in our case, followed by 'l' --- it just copies the (first) '%l' and
>  discards the second 'l', to the effect of having the following error:
>
>  13:54:21 <@danielsh> subversion/libsvn_subr/svn_string.c:781: (apr_err=200004)
>  13:54:21 <@danielsh> svnadmin: E200004: Number '542543543543543543543115' is out of range '[%ld, %ld]'

The problem is APR is a bit more subtle than that, and has been
reported there at least a couple of times. It essentially deals with
APRs inability to parse '%lld' and friends, and involves skipping
arguments (which may lead to segfaults, rather than just errors).

In the APR issue tracker:
https://issues.apache.org/bugzilla/show_bug.cgi?id=48476
In the Subversion issue tracker:
http://subversion.tigris.org/issues/show_bug.cgi?id=3829

This problem has been quite evident on Mac OS where APR_INT64_FMT_T is
defined as 'lld'. So much so, that local ports, such as Macports,
have been patching the above define to simply 'ld', which then cause
gcc to issues bunch of warnings. A rather inconvenient mess, that.

However, rumor is that APR 1.4.4, just released today, actually
includes a fix for the above parsing bug (r1060106 on the 1.4.x
branch). I'm having bit of trouble actually testing it however, so if
I do, I'll report back here. (If somebody else wants to test and
report, that'd be great.)

(But, as Brane mentioned elsethread, we should be using the
APR-provided format strings whenever possible.)

-Hyrum
Received on 2011-05-09 18:02:51 CEST

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.