mirror of
https://github.com/opencv/opencv.git
synced 2025-08-06 14:36:36 +08:00
Fixed buffer overrun; removed the last two uses of sprintf
Fixed an off-by-1 buffer resize, the space for the null termination was forgotten. Prefer snprintf, which can never overflow (if given the right size). In one case I cheated and used strcpy, because I cannot figure out the buffer size at that point in the code.
This commit is contained in:
parent
abda763073
commit
d792ebc5d2
@ -308,8 +308,8 @@ public:
|
||||
|
||||
if( !multiline )
|
||||
{
|
||||
ptr = fs->resizeWriteBuffer( ptr, len + 9 );
|
||||
sprintf( ptr, "<!-- %s -->", comment );
|
||||
ptr = fs->resizeWriteBuffer( ptr, len + 5+4+1 );
|
||||
snprintf( ptr, len + 5+4+1, "<!-- %s -->", comment );
|
||||
len = (int)strlen(ptr);
|
||||
}
|
||||
else
|
||||
@ -344,7 +344,7 @@ public:
|
||||
fs->setBufferPtr(ptr);
|
||||
ptr = fs->flush();
|
||||
}
|
||||
sprintf( ptr, "-->" );
|
||||
strcpy( ptr, "-->" );
|
||||
fs->setBufferPtr(ptr + 3);
|
||||
fs->flush();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user