From 26aa519803f2054c4801f3b0fc665417027e44ed Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 20 Jun 2016 17:39:57 +0100 Subject: [PATCH] Added string termination --- src/osgPlugins/txp/trpage_rarchive.cpp | 2 +- src/osgPlugins/txp/trpage_read.h | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/osgPlugins/txp/trpage_rarchive.cpp b/src/osgPlugins/txp/trpage_rarchive.cpp index 5eecd8d31..367fd2cd3 100644 --- a/src/osgPlugins/txp/trpage_rarchive.cpp +++ b/src/osgPlugins/txp/trpage_rarchive.cpp @@ -54,7 +54,7 @@ int32 trpgr_Archive::GetHeaderData(char *dataPtr, int length, FILE *filehandle) // Set the directory where the archive is void trpgr_Archive::SetDirectory(const char *in_dir) { - strncpy(dir,in_dir,1024); + strncpy(dir,in_dir,DIR_SIZE-1); dir[DIR_SIZE-1] = 0; } // Open File diff --git a/src/osgPlugins/txp/trpage_read.h b/src/osgPlugins/txp/trpage_read.h index d7e4e367a..2bfe0e031 100644 --- a/src/osgPlugins/txp/trpage_read.h +++ b/src/osgPlugins/txp/trpage_read.h @@ -177,6 +177,8 @@ TX_EXDECL class TX_CLDECL trpgrImageHelper bool separateGeoTyp; }; +#define DIR_SIZE 1024 + /* Paging Archive (read version) This just reads the first bits of the file (and the header) and lets you parse from there. @@ -229,7 +231,7 @@ protected: FILE *fp; int fid; // Header info - char dir[1024]; + char dir[DIR_SIZE]; trpgHeader header; trpgMatTable materialTable; trpgTexTable texTable;