win32 dbus-launch.bat replacement

Thiago Macieira thiago at
Sat May 26 07:48:39 PDT 2007

Ralf Habacker wrote:
>Thiago Macieira schrieb:
>> Ralf Habacker wrote:
>>>     if ((p = strrchr(dbusDaemonPath,'\\'))) {
>>>         *(p+1)= '\0';
>>>         strcat(dbusDaemonPath,"dbus-daemon.exe");
>>>     }
>> This and all other sections like it have the problem of buffer
>> overruns.
>> dbusDaemonPath is MAX_PATH bytes in length, but if the
>> GetModuleFileName syscall returns something more than MAX_PATH-15,
>> you'll overrun the end of the buffer when you do strcat.
>Then allocating MAX_PATH*2 should solve the problem for any case ?

Not sure. I guess it would be an overkill.

If Windows can't handle more than MAX_PATH paths anywhere on the system, 
then D-Bus surely can't be installed in a place where that limit would be 
reached. However, it could still mean crashes.

So, if you allocate MAX_PATH + 1 + the max length of any of the strings 
you strcat, you'll always be safe.

Another alternative is to use strncat.

  Thiago Macieira  -  thiago (AT) - thiago (AT)
    PGP/GPG: 0x6EF45358; fingerprint:
    E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : 

More information about the dbus mailing list