mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 07:13:02 +04:00
Merge pull request #22149 from seanm:sprintf
Replaced sprintf with safer snprintf * Straightforward replacement of sprintf with safer snprintf * Trickier replacement of sprintf with safer snprintf Some functions were changed to take another parameter: the size of the buffer, so that they can pass that size on to snprintf.
This commit is contained in:
@@ -469,7 +469,7 @@ int main(int argc, char** argv)
|
||||
outbarename = strrchr(outprefix.c_str(), '/');
|
||||
const char* tmp = strrchr(outprefix.c_str(), '\\');
|
||||
char cmd[1000];
|
||||
sprintf(cmd, "mkdir %s", outprefix.c_str());
|
||||
snprintf(cmd, sizeof(cmd), "mkdir %s", outprefix.c_str());
|
||||
if( tmp && tmp > outbarename )
|
||||
outbarename = tmp;
|
||||
if( outbarename )
|
||||
@@ -568,7 +568,7 @@ int main(int argc, char** argv)
|
||||
char path[1000];
|
||||
for(;frameIdx < maxFrameIdx;frameIdx++)
|
||||
{
|
||||
sprintf(path, "%s%04d.jpg", outprefix.c_str(), frameIdx);
|
||||
snprintf(path, sizeof(path), "%s%04d.jpg", outprefix.c_str(), frameIdx);
|
||||
FILE* f = fopen(path, "rb");
|
||||
if( !f )
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user