1
0
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:
Sean McBride
2022-06-24 23:48:22 -04:00
committed by GitHub
parent a6ca48a1c2
commit 35f1a90df7
34 changed files with 126 additions and 131 deletions
+2 -2
View File
@@ -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;