Safe strncpy method to translate HMT file
Some checks failed
JCS-Prod/RSE-Model/pipeline/pr-master There was a failure building this commit
Some checks failed
JCS-Prod/RSE-Model/pipeline/pr-master There was a failure building this commit
This commit is contained in:
parent
e06dc4e0c8
commit
f784d1b8aa
@ -12,9 +12,13 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#include <io.h>
|
||||||
|
#define F_OK 0
|
||||||
|
#define access _access
|
||||||
#else
|
#else
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
#include <RSPModel.h>
|
#include <RSPModel.h>
|
||||||
@ -22,6 +26,8 @@
|
|||||||
#include "model_export.h"
|
#include "model_export.h"
|
||||||
#include "lib_interface.h"
|
#include "lib_interface.h"
|
||||||
|
|
||||||
|
#define MAX_STR_VAR 1024
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Internal functions declarations
|
* Internal functions declarations
|
||||||
@ -75,7 +81,7 @@ static unsigned int mainProcess(int args_cnt, char* args_value[], T_PROG_OPTIONS
|
|||||||
unsigned short file_index;
|
unsigned short file_index;
|
||||||
RSPMODEL_PARAMETERS libParams;
|
RSPMODEL_PARAMETERS libParams;
|
||||||
T_RSPMODEL_HOB* hobStruct = NULL;
|
T_RSPMODEL_HOB* hobStruct = NULL;
|
||||||
char hmt_filename[1024];
|
char hmt_filename[MAX_STR_VAR] = {0};
|
||||||
void* hmtStruct = NULL;
|
void* hmtStruct = NULL;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
@ -98,10 +104,19 @@ static unsigned int mainProcess(int args_cnt, char* args_value[], T_PROG_OPTIONS
|
|||||||
|
|
||||||
// If Texture module loaded, process HMT file for mtl naming (doesn't extract texture!)
|
// If Texture module loaded, process HMT file for mtl naming (doesn't extract texture!)
|
||||||
if (p_opts->texture_module) {
|
if (p_opts->texture_module) {
|
||||||
hmtStruct = RSPTexture_createHMT();
|
if (strlen(args_value[file_index]) >= MAX_STR_VAR) return RSPLIB_ERROR_GENERIC;
|
||||||
|
|
||||||
strncpy(hmt_filename, args_value[file_index], strlen(args_value[file_index]) - 3);
|
strncpy(hmt_filename, args_value[file_index], strlen(args_value[file_index]) - 3);
|
||||||
|
hmt_filename[strlen(args_value[file_index]) - 1] = 0; //C6053 fix
|
||||||
strncat(hmt_filename, "HMT", strlen(args_value[file_index]));
|
strncat(hmt_filename, "HMT", strlen(args_value[file_index]));
|
||||||
RSPTexture_processHMTFile(hmtStruct, hmt_filename, 0);
|
|
||||||
|
if (access(hmt_filename, F_OK) == 0) {
|
||||||
|
hmtStruct = RSPTexture_createHMT();
|
||||||
|
RSPTexture_processHMTFile(hmtStruct, hmt_filename, 0);
|
||||||
|
} else {
|
||||||
|
printf("[ERR] HMT file '%s' not found for mtl processing!\n", hmt_filename);
|
||||||
|
return RSPLIB_ERROR_GENERIC;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else return RSPLIB_ERROR_MEMORY;
|
} else return RSPLIB_ERROR_MEMORY;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user