https://git.reactos.org/?p=reactos.git;a=commitdiff;h=e3622ebe4e8ae9e8ca4b2a...
commit e3622ebe4e8ae9e8ca4b2ad8c3aef8f52730ca3e Author: Katayama Hirofumi MZ katayama.hirofumi.mz@gmail.com AuthorDate: Thu Dec 16 10:47:57 2021 +0900 Commit: GitHub noreply@github.com CommitDate: Thu Dec 16 10:47:57 2021 +0900
[NTGDI] Strictly check pen style (#4164)
- Check the pen style and elegantly fail if the style was wrong. CORE-13819 --- win32ss/gdi/ntgdi/pen.c | 57 +++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 46 insertions(+), 11 deletions(-)
diff --git a/win32ss/gdi/ntgdi/pen.c b/win32ss/gdi/ntgdi/pen.c index 76b6cd2a2f8..d3edbddc494 100644 --- a/win32ss/gdi/ntgdi/pen.c +++ b/win32ss/gdi/ntgdi/pen.c @@ -115,11 +115,54 @@ IntGdiExtCreatePen( DPRINT("Can't allocate pen\n"); return 0; } + hPen = pbrushPen->BaseObject.hHmgr;
- // If nWidth is zero, the pen is a single pixel wide, regardless of the current transformation. - if ((bOldStylePen) && (!dwWidth) && ((dwPenStyle & PS_STYLE_MASK) != PS_SOLID)) - dwWidth = 1; + if (bOldStylePen) + { + // If nWidth is zero, the pen is a single pixel wide, regardless of the current transformation. + if (!dwWidth && (dwPenStyle & PS_STYLE_MASK) != PS_SOLID) + dwWidth = 1; + } + else + { + switch (dwPenStyle & PS_ENDCAP_MASK) + { + case PS_ENDCAP_ROUND: + case PS_ENDCAP_SQUARE: + case PS_ENDCAP_FLAT: + break; + + default: + goto ExitCleanup; + } + + switch (dwPenStyle & PS_JOIN_MASK) + { + case PS_JOIN_ROUND: + case PS_JOIN_BEVEL: + case PS_JOIN_MITER: + break; + + default: + goto ExitCleanup; + } + + switch (dwPenStyle & PS_TYPE_MASK) + { + case PS_COSMETIC: + if (dwWidth != 1 || ulBrushStyle != BS_SOLID) + goto ExitCleanup; + + break; + + case PS_GEOMETRIC: + break; + + default: + goto ExitCleanup; + } + }
pbrushPen->lWidth = dwWidth; FLOATOBJ_SetLong(&pbrushPen->eWidth, pbrushPen->lWidth); @@ -131,16 +174,8 @@ IntGdiExtCreatePen( pbrushPen->dwStyleCount = 0; pbrushPen->pStyle = NULL; pbrushPen->ulStyleSize = 0; - pbrushPen->flAttrs = bOldStylePen ? BR_IS_OLDSTYLEPEN : BR_IS_PEN;
- // If dwPenStyle is PS_COSMETIC, the width must be set to 1. - if ( !(bOldStylePen) && ((dwPenStyle & PS_TYPE_MASK) == PS_COSMETIC) && ( dwWidth != 1) ) - goto ExitCleanup; - // If dwPenStyle is PS_COSMETIC, the brush style must be BS_SOLID. - if ( !(bOldStylePen) && ((dwPenStyle & PS_TYPE_MASK) == PS_COSMETIC) && (ulBrushStyle != BS_SOLID) ) - goto ExitCleanup; - switch (dwPenStyle & PS_STYLE_MASK) { case PS_NULL: