[PATCH 4/6] winealsa.drv: Append hw address to handle to prevent name collision. (resend)
wine-devel at kievinfo.com
Sun Aug 29 23:09:48 CDT 2010
On 08/29/2010 12:43 AM, Jeff Cook wrote:
> On Tue, Aug 3, 2010 at 7:49 AM, Vitaliy Margolen
> <wine-devel at kievinfo.com> wrote:
>>> + memcpy(ww->ds_desc.szDesc, description,
>>> + min( (sizeof(ww->ds_desc.szDesc) - 1), strlen(description))
>> This does not guarantee that ww->ds_desc.szDesc will be \0 terminated.
> What do you want me to do? This looks pretty safe to me and I just
> copied the block from elsewhere and replaced the variables. Do you
> want me to manually read to the end of ww->ds_desc.szDesc and replace
> with a \0? Sorry for the noobness.
strlen returns number of characters without terminating \0. If you using
memcpy to copy strings you must add additional byte (if destination is big
enough). Or explicitly zero terminate the destination string (if result was
What you really want is a strlcpy() which unfortunately not present on all
platforms. And don't even think using strncpy - it's the worst string
function ever made.
Just the fact that you copied the exact code doesn't automatically make it
More information about the wine-devel