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

Maarten Lankhorst m.b.lankhorst at gmail.com
Tue Feb 16 15:16:43 CST 2010


Hello Marcus,

2010/2/15, Marcus Meissner <meissner at suse.de>:
> Hi,
>
> Writing over the end of a struct via char[1] is only well defined if the
> struct
> is standalone and not contained in another struct.
>
> So for gcc 4.5 the strcpy triggers a fortify overflow error and we
> better use memcpy.
>
> Ciao, Marcus
> ---
>  dlls/shell32/pidl.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/dlls/shell32/pidl.c b/dlls/shell32/pidl.c
> index 3e61144..a7704b3 100644
> --- a/dlls/shell32/pidl.c
> +++ b/dlls/shell32/pidl.c
> @@ -1606,7 +1606,7 @@ LPITEMIDLIST _ILCreateEntireNetwork(void)
>          LPPIDLDATA pData = _ILGetDataPointer(pidlOut);
>
>          pData->u.network.dummy = 0;
> -        strcpy(pData->u.network.szNames, "Entire Network");
> +        memcpy(pData->u.network.szNames, "Entire Network", sizeof("Entire
> Network")+1);
This is wrong, sizeof() already takes the nul character in account,
either use sizeof() or strlen() + 1.

Cheers,
Maarten.



More information about the wine-devel mailing list