Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
cd64b504
Commit
cd64b504
authored
Jan 09, 2018
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
imgcodecs: add overflow checks
imgcodecs: remove assert() usage Origin commits: -
be524792
-
8a76fada
parent
443059e3
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
21 additions
and
14 deletions
+21
-14
bitstrm.cpp
modules/highgui/src/bitstrm.cpp
+14
-8
grfmt_bmp.cpp
modules/highgui/src/grfmt_bmp.cpp
+1
-0
grfmt_sunras.cpp
modules/highgui/src/grfmt_sunras.cpp
+4
-4
precomp.hpp
modules/highgui/src/precomp.hpp
+1
-1
utils.cpp
modules/highgui/src/utils.cpp
+1
-1
No files found.
modules/highgui/src/bitstrm.cpp
View file @
cd64b504
...
...
@@ -42,6 +42,7 @@
#include "precomp.hpp"
#include "bitstrm.hpp"
#include "utils.hpp"
namespace
cv
{
...
...
@@ -164,7 +165,7 @@ void RBaseStream::release()
void
RBaseStream
::
setPos
(
int
pos
)
{
assert
(
isOpened
()
&&
pos
>=
0
);
CV_Assert
(
isOpened
()
&&
pos
>=
0
);
if
(
!
m_file
)
{
...
...
@@ -181,14 +182,19 @@ void RBaseStream::setPos( int pos )
int
RBaseStream
::
getPos
()
{
assert
(
isOpened
()
);
return
m_block_pos
+
(
int
)(
m_current
-
m_start
);
CV_Assert
(
isOpened
());
int
pos
=
validateToInt
((
m_current
-
m_start
)
+
m_block_pos
);
CV_Assert
(
pos
>=
m_block_pos
);
// overflow check
CV_Assert
(
pos
>=
0
);
// overflow check
return
pos
;
}
void
RBaseStream
::
skip
(
int
bytes
)
{
assert
(
bytes
>=
0
);
CV_Assert
(
bytes
>=
0
);
uchar
*
old
=
m_current
;
m_current
+=
bytes
;
CV_Assert
(
m_current
>=
old
);
// overflow check
}
///////////////////////// RLByteStream ////////////////////////////
...
...
@@ -220,7 +226,7 @@ int RLByteStream::getBytes( void* buffer, int count )
{
uchar
*
data
=
(
uchar
*
)
buffer
;
int
readed
=
0
;
assert
(
count
>=
0
);
CV_Assert
(
count
>=
0
);
while
(
count
>
0
)
{
...
...
@@ -371,7 +377,7 @@ void WBaseStream::writeBlock()
{
int
size
=
(
int
)(
m_current
-
m_start
);
assert
(
isOpened
()
);
CV_Assert
(
isOpened
()
);
if
(
size
==
0
)
return
;
...
...
@@ -442,7 +448,7 @@ void WBaseStream::release()
int
WBaseStream
::
getPos
()
{
assert
(
isOpened
()
);
CV_Assert
(
isOpened
()
);
return
m_block_pos
+
(
int
)(
m_current
-
m_start
);
}
...
...
@@ -465,7 +471,7 @@ void WLByteStream::putBytes( const void* buffer, int count )
{
uchar
*
data
=
(
uchar
*
)
buffer
;
assert
(
data
&&
m_current
&&
count
>=
0
);
CV_Assert
(
data
&&
m_current
&&
count
>=
0
);
while
(
count
)
{
...
...
modules/highgui/src/grfmt_bmp.cpp
View file @
cd64b504
...
...
@@ -92,6 +92,7 @@ bool BmpDecoder::readHeader()
m_offset
=
m_strm
.
getDWord
();
int
size
=
m_strm
.
getDWord
();
CV_Assert
(
size
>
0
);
// overflow, 2Gb limit
if
(
size
>=
36
)
{
...
...
modules/highgui/src/grfmt_sunras.cpp
View file @
cd64b504
...
...
@@ -120,7 +120,7 @@ bool SunRasterDecoder::readHeader()
m_type
=
IsColorPalette
(
m_palette
,
m_bpp
)
?
CV_8UC3
:
CV_8UC1
;
m_offset
=
m_strm
.
getPos
();
assert
(
m_offset
==
32
+
m_maplength
);
CV_Assert
(
m_offset
==
32
+
m_maplength
);
result
=
true
;
}
}
...
...
@@ -133,7 +133,7 @@ bool SunRasterDecoder::readHeader()
m_offset
=
m_strm
.
getPos
();
assert
(
m_offset
==
32
+
m_maplength
);
CV_Assert
(
m_offset
==
32
+
m_maplength
);
result
=
true
;
}
}
...
...
@@ -226,7 +226,7 @@ bool SunRasterDecoder::readData( Mat& img )
code
=
m_strm
.
getByte
();
if
(
len
>
line_end
-
tsrc
)
{
assert
(
0
);
CV_Error
(
CV_StsInternal
,
""
);
goto
bad_decoding_1bpp
;
}
...
...
@@ -367,7 +367,7 @@ bad_decoding_end:
result
=
true
;
break
;
default
:
assert
(
0
);
CV_Error
(
CV_StsInternal
,
""
);
}
}
catch
(
...
)
...
...
modules/highgui/src/precomp.hpp
View file @
cd64b504
...
...
@@ -54,7 +54,7 @@
#include <string.h>
#include <limits.h>
#include <ctype.h>
#include <assert.h>
#include <assert.h>
// FIX IT: remove this
#if defined WIN32 || defined WINCE
#if !defined _WIN32_WINNT
...
...
modules/highgui/src/utils.cpp
View file @
cd64b504
...
...
@@ -670,7 +670,7 @@ cvConvertImage( const CvArr* srcarr, CvArr* dstarr, int flags )
icvCvt_BGR2Gray_8u_C3C1R
(
s
,
s_step
,
d
,
d_step
,
size
,
swap_rb
);
break
;
case
33
:
assert
(
swap_rb
);
CV_Assert
(
swap_rb
);
icvCvt_RGB2BGR_8u_C3R
(
s
,
s_step
,
d
,
d_step
,
size
);
break
;
case
41
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment