Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

contrib/hbwin: Fixed dangling pointer access in WIN_DRAWBITMAP(). #335

Merged
merged 1 commit into from
Nov 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions ChangeLog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
Entries may not always be in chronological/commit order.
See license at the end of file. */

2023-11-11 21:41 UTC+0100 Phil Krylov (phil a t krylov.eu)
* contrib/hbwin/win_bmp.c
! Fixed dangling pointer access (introduced in commit 64dba82) in
WIN_DRAWBITMAP().

2023-11-11 21:08 UTC+0100 Phil Krylov (phil a t krylov.eu)
* .github/workflows/linux-ci.yml
* .github/workflows/macos-ci.yml
Expand Down
9 changes: 4 additions & 5 deletions contrib/hbwin/win_bmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,17 +166,18 @@ HB_FUNC( WIN_DRAWBITMAP )
BITMAPINFO * pbmi = NULL;
BYTE * pBits = NULL;
HDC hDC = hbwapi_par_HDC( 1 );
/* FIXME: No check is done on 2nd parameter which is a large security hole
and may cause GPF in simple error cases.
[vszakats] */
HB_SIZE nSize = hb_parclen( 2 );
BITMAPFILEHEADER * pbmfh = ( BITMAPFILEHEADER * ) hb_parc( 2 );
int iType = hbwin_bitmapType( pbmfh, nSize );

/* FIXME: No check is done on 2nd parameter which is a large security hole
and may cause GPF in simple error cases.
[vszakats] */
if( hbwin_bitmapIsSupported( hDC, iType, pbmfh, nSize ) == 0 )
{
int iWidth = hb_parni( 7 );
int iHeight = hb_parni( 8 );
BITMAPINFO bmi;

if( iType == HB_WIN_BITMAP_BMP )
{
Expand All @@ -197,8 +198,6 @@ HB_FUNC( WIN_DRAWBITMAP )
}
else if( iWidth && iHeight )
{
BITMAPINFO bmi;

memset( &bmi, 0, sizeof( bmi ) );
bmi.bmiHeader.biSize = sizeof( BITMAPINFO );
bmi.bmiHeader.biWidth = iWidth;
Expand Down
Loading