apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Philip Prindeville <philipp_s...@redfish-solutions.com>
Subject Re: %lld/%llu not handled by apr_vformatter
Date Tue, 17 Aug 2010 23:28:01 GMT
  Hey Chris,

I'm assuming this is only happening on a 32-bit native machine, right?

Because on an x86_64 machine '%lu' would be 64-bit and behave correctly, yes?

-Philip


On 8/11/10 8:51 AM, Chris Knight wrote:
> I spent half-a-day yesterday trying to figure out why I was crashing in apr_psprintf
on a strlen until I realized that my "%llu%s" format string was causing it to use my long
long int as a char *.
>
> Needless to say, no harm in adding support for %ll[du] yes?
>
> Ah, 64-bit fun for everyone....
>
> Example code:
>
> #include<apr.h>
> #include<apr_pools.h>
> #include<apr_strings.h>
> #include<stdio.h>
>
> int main(int argc, char **argv) {
>      apr_pool_t *pool = NULL;
>      char *s = "hello world"; u_int64_t v = 12345678;
>
>      apr_pool_initialize(); apr_pool_create(&(pool), NULL);
>      printf("%llu%s", v, s); // works
>      char *f = apr_psprintf(pool, "%llu%s", v, s); // segfault on strlen
>      printf("%s\n", f);
> }


Mime
View raw message