[PATCH] wined3d: Split comments in separate line to avoid buffer overflow when traces are enabled (try 2)

Henri Verbeet hverbeet at gmail.com
Thu Feb 18 04:45:00 CST 2010


On 17 February 2010 17:54, Christian Costa <titan.costa at wanadoo.fr> wrote:
> +            if (TRACE_ON(d3d_shader))
> +            {
> +                int size = strlen(comment) + 1;
> +                char* str = (char*)HeapAlloc(GetProcessHeap(), 0, size);
> +                int i = 0;
> +                char* line = str;
> +                memcpy(str, comment, size);
> +                DPRINTF("//");
> +                while (i < size)
> +                {
> +                    /* Find end of line */
> +                    while ((str[i] != 0) && (str[i] != 0x0a))
> +                        i++;
> +                    /* Terminate line and remove preceding 0x0d if any */
> +                    if (i && (str[i-1] == 0x0d))
> +                        str[i-1] = 0;
> +                    else
> +                        str[i] = 0;
> +                    /* Display line and prepare next line */
> +                    DPRINTF("%s\n", debugstr_an(line, strlen(line)));
> +                    i++;
> +                    line = str + i;
> +                }
> +            }
This code has several obvious issues.



More information about the wine-devel mailing list