Add security checks on file writting

This commit is contained in:
Ray 2019-09-30 17:32:06 +02:00
parent a8e63b9724
commit df84f93938
2 changed files with 56 additions and 51 deletions

View file

@ -910,6 +910,8 @@ void ExportWaveAsCode(Wave wave, const char *fileName)
FILE *txtFile = fopen(fileName, "wt");
if (txtFile != NULL)
{
fprintf(txtFile, "\n//////////////////////////////////////////////////////////////////////////////////\n");
fprintf(txtFile, "// //\n");
fprintf(txtFile, "// WaveAsCode exporter v1.0 - Wave data exported as an array of bytes //\n");
@ -941,6 +943,7 @@ void ExportWaveAsCode(Wave wave, const char *fileName)
fprintf(txtFile, "0x%x };\n", ((unsigned char *)wave.data)[dataSize - 1]);
fclose(txtFile);
}
}
// Play a sound

View file

@ -849,12 +849,13 @@ void ExportImageAsCode(Image image, const char *fileName)
{
#define BYTES_TEXT_PER_LINE 20
FILE *txtFile = fopen(fileName, "wt");
if (txtFile != NULL)
{
char varFileName[256] = { 0 };
int dataSize = GetPixelDataSize(image.width, image.height, image.format);
FILE *txtFile = fopen(fileName, "wt");
fprintf(txtFile, "\n");
fprintf(txtFile, "////////////////////////////////////////////////////////////////////////////////////////\n");
fprintf(txtFile, "// //\n");
fprintf(txtFile, "// ImageAsCode exporter v1.0 - Image pixel data exported as an array of bytes //\n");
@ -881,6 +882,7 @@ void ExportImageAsCode(Image image, const char *fileName)
fprintf(txtFile, "0x%x };\n", ((unsigned char *)image.data)[dataSize - 1]);
fclose(txtFile);
}
}
// Copy an image to a new image