Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

possible vsprintf/vsnprintf bug



Hi,

Was doing some logging using my own custom IOLog function which in the end call IOLog. see following.

void MyIOLog( char *DebugMessage, ... )
{
char DebugBuffer[256];

va_list ap;
va_start(ap,DebugMessage);

DebugBuffer[0] = '\0';

vsnprintf( DebugBuffer, 256, DebugMessage, ap );
va_end(ap);

IOLog(DebugBuffer);
}

for example:
unsigned long ulTest = 12345678;
unsigned long *pulTest = &ulTest; /// for example the address == 0xABCDEF00

MyIOLog("Test 0x%lX = %ld \n", (unsigned long)pulTest, *pulTest);
IOLog("Test 0x%lX = %ld \n", (unsigned long)pulTest, *pulTest);

With the previous example the IOLog will output
Test 0xABCDEF00 = 12345678

But the MyIOLog line will do something very nasty like
Test 0xA = 75689000
which obviously does not make any sense.

The problem seem to be coming from the 'X' argument, if you replace it by 'x' the output looks fine.
_______________________________________________
darwin-development mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/darwin-development
Do not post admin requests to the list. They will be ignored.


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.