BuildROMS: Cleanup potential buffer overrun and execution with MinGW
As discussed in #717
This commit is contained in:
parent
5e8f48034d
commit
2991ae067d
2 changed files with 12 additions and 9 deletions
13
makefile
13
makefile
|
@ -887,7 +887,7 @@ ifeq ($(WIN32),) #*nix Environments (&& cygwin)
|
||||||
NETWORK_OPT = $(NETWORK_CCDEFS)
|
NETWORK_OPT = $(NETWORK_CCDEFS)
|
||||||
endif
|
endif
|
||||||
ifneq (binexists,$(shell if $(TEST) -e BIN/buildtools; then echo binexists; fi))
|
ifneq (binexists,$(shell if $(TEST) -e BIN/buildtools; then echo binexists; fi))
|
||||||
MKDIRBIN = mkdir -p BIN/buildtools
|
MKDIRBIN = @mkdir -p BIN/buildtools
|
||||||
endif
|
endif
|
||||||
ifeq (commit-id-exists,$(shell if $(TEST) -e .git-commit-id; then echo commit-id-exists; fi))
|
ifeq (commit-id-exists,$(shell if $(TEST) -e .git-commit-id; then echo commit-id-exists; fi))
|
||||||
GIT_COMMIT_ID=$(shell grep 'SIM_GIT_COMMIT_ID' .git-commit-id | awk '{ print $$2 }')
|
GIT_COMMIT_ID=$(shell grep 'SIM_GIT_COMMIT_ID' .git-commit-id | awk '{ print $$2 }')
|
||||||
|
@ -1003,8 +1003,10 @@ else
|
||||||
OS_CCDEFS += -fms-extensions $(PTHREADS_CCDEFS)
|
OS_CCDEFS += -fms-extensions $(PTHREADS_CCDEFS)
|
||||||
OS_LDFLAGS += -lm -lwsock32 -lwinmm $(PTHREADS_LDFLAGS)
|
OS_LDFLAGS += -lm -lwsock32 -lwinmm $(PTHREADS_LDFLAGS)
|
||||||
EXE = .exe
|
EXE = .exe
|
||||||
ifneq (binexists,$(shell if exist BIN\buildtools echo binexists))
|
ifneq (clean,$(MAKECMDGOALS))
|
||||||
MKDIRBIN = if not exist BIN mkdir BIN\buildtools
|
ifneq (buildtoolsexists,$(shell if exist BIN\buildtools (echo buildtoolsexists) else (mkdir BIN\buildtools)))
|
||||||
|
MKDIRBIN=
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
ifneq ($(USE_NETWORK),)
|
ifneq ($(USE_NETWORK),)
|
||||||
NETWORK_OPT += -DUSE_SHARED
|
NETWORK_OPT += -DUSE_SHARED
|
||||||
|
@ -2022,11 +2024,10 @@ ${BUILD_ROMS} :
|
||||||
${MKDIRBIN}
|
${MKDIRBIN}
|
||||||
ifeq ($(WIN32),)
|
ifeq ($(WIN32),)
|
||||||
@if $(TEST) \( ! -e $@ \) -o \( sim_BuildROMs.c -nt $@ \) ; then ${CC} sim_BuildROMs.c $(CC_OUTSPEC); fi
|
@if $(TEST) \( ! -e $@ \) -o \( sim_BuildROMs.c -nt $@ \) ; then ${CC} sim_BuildROMs.c $(CC_OUTSPEC); fi
|
||||||
@$@
|
|
||||||
else
|
else
|
||||||
if not exist $@ ${CC} sim_BuildROMs.c $(CC_OUTSPEC)
|
@if not exist $@ ${CC} sim_BuildROMs.c $(CC_OUTSPEC)
|
||||||
$(@D)\$(@F)
|
|
||||||
endif
|
endif
|
||||||
|
@$@
|
||||||
|
|
||||||
#
|
#
|
||||||
# Individual builds
|
# Individual builds
|
||||||
|
|
|
@ -83,6 +83,7 @@ struct ROM_File_Descriptor {
|
||||||
#include <sys/utime.h>
|
#include <sys/utime.h>
|
||||||
#define utimbuf _utimbuf
|
#define utimbuf _utimbuf
|
||||||
#define utime _utime
|
#define utime _utime
|
||||||
|
#define snprintf _snprintf
|
||||||
#else
|
#else
|
||||||
#include <utime.h>
|
#include <utime.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -206,11 +207,12 @@ if ((c = strchr (array_name, '.')))
|
||||||
*c = '_';
|
*c = '_';
|
||||||
if ((c = strchr (array_name, '/')))
|
if ((c = strchr (array_name, '/')))
|
||||||
*c = '_';
|
*c = '_';
|
||||||
sprintf (include_filename, "%s.h", cleaned_rom_filename);
|
include_filename[sizeof (include_filename) - 1] = '\0';
|
||||||
|
snprintf (include_filename, sizeof (include_filename) - 1, "%s.h", cleaned_rom_filename);
|
||||||
if ((c = strrchr (include_filename, '/')))
|
if ((c = strrchr (include_filename, '/')))
|
||||||
sprintf (c+1, "%s.h", array_name);
|
sprintf (c+1, "%s.h", array_name);
|
||||||
else
|
else
|
||||||
sprintf (include_filename, "%s.h", array_name);
|
snprintf (include_filename, sizeof (include_filename) - 1, "%s.h", array_name);
|
||||||
printf ("The ROMs array entry for this new ROM image file should look something like:\n");
|
printf ("The ROMs array entry for this new ROM image file should look something like:\n");
|
||||||
printf ("{\"%s\", \"%s\", %d, 0x%08X, \"%s\"}\n",
|
printf ("{\"%s\", \"%s\", %d, 0x%08X, \"%s\"}\n",
|
||||||
rom_filename, include_filename, (int)(statb.st_size), checksum, array_name);
|
rom_filename, include_filename, (int)(statb.st_size), checksum, array_name);
|
||||||
|
|
Loading…
Add table
Reference in a new issue