Skip to content

Commit

Permalink
COMP: Fix unsafe usage of sprintf
Browse files Browse the repository at this point in the history
This usage of sprintf can result it buffer overflow. Use the bounded
snprintf.

Change-Id: Ibe58c95ac878685344b16ae3c7ce57d15456bd4d
  • Loading branch information
blowekamp committed Jan 8, 2015
1 parent 6e3a97c commit 3e6a661
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Modules/IO/ImageBase/include/itkImageSeriesWriter.hxx
Expand Up @@ -28,6 +28,11 @@
#include "itkArray.h"
#include "vnl/algo/vnl_determinant.h"
#include <cstdio>

#if defined(_MSC_VER)
#define snprintf _snprintf
#endif // _MSC_VER

namespace itk
{
//---------------------------------------------------------
Expand Down Expand Up @@ -155,7 +160,7 @@ ImageSeriesWriter< TInputImage, TOutputImage >

for ( unsigned int slice = 0; slice < numberOfFiles; slice++ )
{
sprintf (fileName, m_SeriesFormat.c_str(), fileNumber);
snprintf (fileName, IOCommon::ITK_MAXPATHLEN + 1, m_SeriesFormat.c_str(), fileNumber);
m_FileNames.push_back(fileName);
fileNumber += this->m_IncrementIndex;
}
Expand Down

0 comments on commit 3e6a661

Please sign in to comment.