Skip to content

Commit 0318e12

Browse files
committed
Replace sprintf_s with snprintf
The snprintf function is a part of the C99 standard library, included in the <stdio.h> header.
1 parent 169f8ad commit 0318e12

7 files changed

Lines changed: 10 additions & 10 deletions

File tree

src/JiFFI2.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@ void JiFFI2::cmd_uploadBJL_Click(void)
636636
create_bjl();
637637
// create the file name
638638
char file[MAX_PATH], buffer[10];
639-
sprintf_s(file, "%s%s_load_%06x_run_%06x_jiffi%i.bjl", out, name, loadadr, runadr, chk_JiFFI.Value);
639+
snprintf(file, sizeof(file), "%s%s_load_%06x_run_%06x_jiffi%i.bjl", out, name, loadadr, runadr, chk_JiFFI.Value);
640640
printf("\nCreate temporary file %s\n", file);
641641
// create the command arguments
642642
QStringList arguments;
@@ -692,7 +692,7 @@ void JiFFI2::HandleSkunkboardTempROM0(void)
692692
dopatches();
693693
create_rom(0);
694694
// create the file name
695-
sprintf_s(file, "%s%s_jiffi%i.rom", out, name, chk_JiFFI.Value);
695+
snprintf(file, sizeof(file), "%s%s_jiffi%i.rom", out, name, chk_JiFFI.Value);
696696
printf("\nCreate temporary file %s\n", file);
697697
// create the command arguments
698698
QStringList arguments;
@@ -893,7 +893,7 @@ void JiFFI2::cmd_uploadskunk_Click(void)
893893
create_coff();
894894
// create the file name
895895
char file[MAX_PATH];
896-
sprintf_s(file, "%s%s_jiffi%i.coff", out, name, chk_JiFFI.Value);
896+
snprintf(file, sizeof(file), "%s%s_jiffi%i.coff", out, name, chk_JiFFI.Value);
897897
printf("\nCreate temporary file %s\n", file);
898898
// create the command line
899899
QStringList arguments;

src/bjl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ int create_bjl(void)
99

1010
// create output filename based on the header
1111
char n[MAX_PATH];
12-
sprintf_s(n, "%s%s_load_%06x_run_%06x_jiffi%i.bjl", out, name, loadadr, runadr, chk_JiFFI.Value);
12+
snprintf(n, sizeof(n), "%s%s_load_%06x_run_%06x_jiffi%i.bjl", out, name, loadadr, runadr, chk_JiFFI.Value);
1313

1414
// Check if file already exists
1515
if (!chk_overwrite.Value && !fopen_s(&file3, n, "rb") && file3 && !fclose(file3))

src/coff.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ int create_coff(void)
148148

149149
// create output filename
150150
char buffer[MAX_PATH];
151-
sprintf_s(buffer, "%s%s_jiffi%i.coff", out, name, chk_JiFFI.Value);
151+
snprintf(buffer, sizeof(buffer), "%s%s_jiffi%i.coff", out, name, chk_JiFFI.Value);
152152

153153
// Check if file already exists
154154
if (!chk_overwrite.Value && !fopen_s(&file2, buffer, "rb") && file2 && !fclose(file2))

src/elf.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ int create_elf(void)
6363

6464
// create output filename based on the header
6565
char n[MAX_PATH];
66-
sprintf_s(n, "%s%s_jiffi%i.elf", out, name, chk_JiFFI.Value);
66+
snprintf(n, sizeof(n), "%s%s_jiffi%i.elf", out, name, chk_JiFFI.Value);
6767

6868
// Check if file already exists
6969
if (!chk_overwrite.Value && !fopen_s(&file3, n, "rb") && file3 && !fclose(file3))

src/jagr2.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ int create_jagv2(void)
1212

1313
// create output filename based on the header
1414
char n[MAX_PATH];
15-
sprintf_s(n, "%s%s_jagserver2_jiffi%i.prg", out, name, chk_JiFFI.Value);
15+
snprintf(n, sizeof(n), "%s%s_jagserver2_jiffi%i.prg", out, name, chk_JiFFI.Value);
1616

1717
// Check if file already exists
1818
if (!chk_overwrite.Value && !fopen_s(&file3, n, "rb") && file3 && !fclose(file3))

src/jagr3.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ int create_jagv3(void)
1212

1313
// create output filename based on the header
1414
char n[MAX_PATH];
15-
sprintf_s(n, "%s%s_jagserver3_jiffi%i.prg", out, name, chk_JiFFI.Value);
15+
snprintf(n, sizeof(n), "%s%s_jagserver3_jiffi%i.prg", out, name, chk_JiFFI.Value);
1616

1717
// Check if file already exists
1818
if (!chk_overwrite.Value && !fopen_s(&file3, n, "rb") && file3 && !fclose(file3))

src/rom.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ int create_rom(int header)
1818

1919
// create output filename based on the header
2020
char n[MAX_PATH];
21-
sprintf_s(n, "%s%s_jiffi%i%s", out, name, chk_JiFFI.Value, HeaderROMName[header]);
21+
snprintf(n, sizeof(n), "%s%s_jiffi%i%s", out, name, chk_JiFFI.Value, HeaderROMName[header]);
2222

2323
// Check if file already exists
2424
if (!chk_overwrite.Value && !fopen_s(&file3, n, "rb") && file3 && !fclose(file3))
@@ -88,7 +88,7 @@ int convert_rom(int _out)
8888

8989
// create output filename based on the header
9090
char n[MAX_PATH];
91-
sprintf_s(n, "%s%s%s", out, name, HeaderROMName[_out]);
91+
snprintf(n, sizeof(n), "%s%s%s", out, name, HeaderROMName[_out]);
9292

9393
// Check if file already exists
9494
if (!chk_overwrite.Value && !fopen_s(&file3, n, "rb") && file3 && !fclose(file3))

0 commit comments

Comments
 (0)