[PATCH] shell32: replace strcpy by memcpy due to slightly undefined struct handling

Paul Chitescu paulc at voip.null.ro
Mon Feb 15 10:46:06 CST 2010


> -        strcpy(pData->u.network.szNames, "Entire Network");
> +        memcpy(pData->u.network.szNames, "Entire Network", sizeof("Entire 
Network")+1);

Please use a const buffer as "Entire Network" is a string literal, not 
something with a clearly defined size (not even talking about length).

const char entireNetwork[] = "Entire Network";
...
memcpy(pData->u.network.szNames, entireNetwork, sizeof(entireNetwork));

The final NUL is part of the char array. Regardless, we may still copy some 
garbage after the NUL depending if/how the compiler pads the buffer.

Probably a better way would be to simply cast (char*)pData->u.network.szNames 
since the length is not checked anyway.

Regards,

Paul




More information about the wine-devel mailing list