Commit 1c6899c4 authored by Cory Quammen's avatar Cory Quammen

Avoid warnings about string truncation caused by string ops

parent 111d0c84
......@@ -46,6 +46,7 @@
#include "vtkIntArray.h"
#include "vtkLongArray.h"
#include "vtkLookupTable.h"
#include "vtkMath.h"
#include "vtkObjectFactory.h"
#include "vtkPointData.h"
#include "vtkPoints.h"
......@@ -685,7 +686,7 @@ void vtkEnSightWriter::WriteCaseFile(int TotalTimeSteps)
char charBuffer[512];
char charBuffer[1024];
//open the geometry file
......@@ -713,7 +714,7 @@ void vtkEnSightWriter::WriteCaseFile(int TotalTimeSteps)
char fileBuffer[512];
char fileBuffer[256];
//write the Node variable files
for (i=0;i<input->GetPointData()->GetNumberOfArrays();i++)
......@@ -909,10 +910,13 @@ void vtkEnSightWriter::WriteSOSCaseFile(int numProcs)
void vtkEnSightWriter::WriteStringToFile(const char* cstring, FILE* file)
char cbuffer[81];
// Terminate the buffer to avoid static analyzer warnings about strncpy not
// NUL-terminating its destination buffer in case the input is too long.
cbuffer[80] = '\0';
unsigned long cstringLength = static_cast<unsigned long>(strlen(cstring));
for (int i = cstringLength; i < 81; ++i)
cbuffer[i] = '\0';
// Write a constant 80 bytes to the file.
fwrite(cbuffer, sizeof(char),80,file);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment