[Nagiosplug-devel] bug in included asprintf (lib/snprintf.c)?

sean finney seanius at seanius.net
Sat Aug 21 17:50:03 CEST 2004


i've spent the past couple hours trying to figure this one out, and
think i've finally nailed it.  i think asprintf (or something it calls)
 has trouble with non-standard ints.  that is, unsigned long long illicits
 some strange behavior:

#include <stdio.h>
#include "../config.h"

int main(){
        char *ptr=NULL;
        unsigned long long one=1;
        int two=2;
        ptr=strdup("");
        asprintf(&ptr, "%s [%llu (%d%%)]", ptr, one, two);
        printf("ptr is: %s\n", ptr);
        return 0;
}

produces:

ptr is:  [0 (1%)]

huh?

(fwiw, this is on solaris 8, gcc 3.0.4)

	sean

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://nagios-plugins.org/archive/devel/attachments/20040821/91d91361/attachment.sig>


More information about the Devel mailing list