Skip to content

Commit bc3aaf4

Browse files
committed
check for input buffer size on datastream::gets
1 parent 1dbed6b commit bc3aaf4

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

Diff for: src/libraw_datastream.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ INT64 LibRaw_file_datastream::tell()
287287

288288
char *LibRaw_file_datastream::gets(char *str, int sz)
289289
{
290+
if(sz<1) return NULL;
290291
LR_STREAM_CHK();
291292
std::istream is(f.get());
292293
is.getline(str, sz);
@@ -421,6 +422,7 @@ INT64 LibRaw_buffer_datastream::tell()
421422

422423
char *LibRaw_buffer_datastream::gets(char *s, int sz)
423424
{
425+
if(sz<1) return NULL;
424426
unsigned char *psrc, *pdest, *str;
425427
str = (unsigned char *)s;
426428
psrc = buf + streampos;
@@ -618,6 +620,7 @@ INT64 LibRaw_bigfile_datastream::tell()
618620

619621
char *LibRaw_bigfile_datastream::gets(char *str, int sz)
620622
{
623+
if(sz<1) return NULL;
621624
LR_BF_CHK();
622625
return fgets(str, sz, f);
623626
}

0 commit comments

Comments
 (0)