From: Andrew Eikum Subject: Re: [PATCH 3/3] msacm32: Use a helper to validate stream pointers Message-Id: <20160829133903.GM5058@foghorn.codeweavers.com> Date: Mon, 29 Aug 2016 08:39:03 -0500 In-Reply-To: <20160828070730.14846-3-00cpxxx@gmail.com> References: <20160828070730.14846-1-00cpxxx@gmail.com> <20160828070730.14846-3-00cpxxx@gmail.com> Signed-off-by: Andrew Eikum On Sun, Aug 28, 2016 at 04:07:30AM -0300, Bruno Jesus wrote: > Signed-off-by: Bruno Jesus <00cpxxx@gmail.com> > --- > dlls/msacm32/stream.c | 25 +++++++++++++------------ > 1 file changed, 13 insertions(+), 12 deletions(-) > > diff --git a/dlls/msacm32/stream.c b/dlls/msacm32/stream.c > index 4b4976f..6e81151 100644 > --- a/dlls/msacm32/stream.c > +++ b/dlls/msacm32/stream.c > @@ -50,6 +50,15 @@ static PWINE_ACMSTREAM ACM_GetStream(HACMSTREAM has) > return (PWINE_ACMSTREAM)has; > } > > +static BOOL ACM_ValidatePointers(PACMDRVSTREAMHEADER padsh) > +{ > + /* check that pointers have not been modified */ > + return !(padsh->pbPreparedSrc != padsh->pbSrc || > + padsh->cbPreparedSrcLength < padsh->cbSrcLength || > + padsh->pbPreparedDst != padsh->pbDst || > + padsh->cbPreparedDstLength < padsh->cbDstLength); > +} > + > /*********************************************************************** > * acmStreamClose (MSACM32.@) > */ > @@ -108,13 +117,9 @@ MMRESULT WINAPI acmStreamConvert(HACMSTREAM has, PACMSTREAMHEADER pash, > */ > padsh = (PACMDRVSTREAMHEADER)pash; > > - /* check that pointers have not been modified */ > - if (padsh->pbPreparedSrc != padsh->pbSrc || > - padsh->cbPreparedSrcLength < padsh->cbSrcLength || > - padsh->pbPreparedDst != padsh->pbDst || > - padsh->cbPreparedDstLength < padsh->cbDstLength) { > + if (!ACM_ValidatePointers(padsh)) { > WARN("invalid parameter\n"); > - return MMSYSERR_INVALPARAM; > + return MMSYSERR_INVALPARAM; > } > > padsh->fdwConvert = fdwConvert; > @@ -467,13 +472,9 @@ MMRESULT WINAPI acmStreamUnprepareHeader(HACMSTREAM has, PACMSTREAMHEADER pash, > */ > padsh = (PACMDRVSTREAMHEADER)pash; > > - /* check that pointers have not been modified */ > - if (padsh->pbPreparedSrc != padsh->pbSrc || > - padsh->cbPreparedSrcLength < padsh->cbSrcLength || > - padsh->pbPreparedDst != padsh->pbDst || > - padsh->cbPreparedDstLength < padsh->cbDstLength) { > + if (!ACM_ValidatePointers(padsh)) { > WARN("invalid parameter\n"); > - return MMSYSERR_INVALPARAM; > + return MMSYSERR_INVALPARAM; > } > > padsh->fdwConvert = fdwUnprepare; > -- > 2.9.3 > > >