Skip to content

Commit 668e338

Browse files
committed
random source and exe name to allow src_sfx == exe_sfx
1 parent 575ca6e commit 668e338

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

bin/ej-compile.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ handle_packet(
500500
if (req->output_only) {
501501
if (req->style_checker && req->style_checker[0]) {
502502
unsigned char src_work_name[PATH_MAX];
503-
snprintf(src_work_name, sizeof(src_work_name), "%06d%s", req->run_id, "" /*lang->src_sfx*/);
503+
snprintf(src_work_name, sizeof(src_work_name), "%llx", random_u64());
504504
unsigned char src_work_path[PATH_MAX];
505505
snprintf(src_work_path, sizeof(src_work_path), "%s/%s", working_dir, src_work_name);
506506

@@ -591,7 +591,7 @@ handle_packet(
591591
}
592592

593593
unsigned char src_work_name[PATH_MAX];
594-
snprintf(src_work_name, sizeof(src_work_name), "%06d%s", req->run_id, lang->src_sfx);
594+
snprintf(src_work_name, sizeof(src_work_name), "%llx%s", random_u64(), lang->src_sfx);
595595
unsigned char src_work_path[PATH_MAX];
596596
snprintf(src_work_path, sizeof(src_work_path), "%s/%s", working_dir, src_work_name);
597597

@@ -615,7 +615,7 @@ handle_packet(
615615
}
616616

617617
if (!req->multi_header) {
618-
snprintf(exe_work_name, PATH_MAX, "%06d%s", req->run_id, lang->exe_sfx);
618+
snprintf(exe_work_name, PATH_MAX, "%llx%s", random_u64(), lang->exe_sfx);
619619
unsigned char exe_work_path[PATH_MAX];
620620
snprintf(exe_work_path, sizeof(exe_work_path), "%s/%s", working_dir, exe_work_name);
621621

@@ -650,7 +650,7 @@ handle_packet(
650650
}
651651

652652
// multi-header mode
653-
snprintf(exe_work_name, PATH_MAX, "%06d%s", req->run_id, lang->exe_sfx);
653+
snprintf(exe_work_name, PATH_MAX, "%llx%s", random_u64(), lang->exe_sfx);
654654
unsigned char exe_work_path[PATH_MAX];
655655
snprintf(exe_work_path, sizeof(exe_work_path), "%s/%s", working_dir, exe_work_name);
656656
zf = ej_libzip_open(log_f, exe_work_path, O_CREAT | O_TRUNC | O_WRONLY);
@@ -835,7 +835,7 @@ handle_packet(
835835
full_s[full_z] = 0;
836836

837837
unsigned char test_src_name[PATH_MAX];
838-
snprintf(test_src_name, sizeof(test_src_name), "%06d_%03d%s", req->run_id, serial, lang->src_sfx);
838+
snprintf(test_src_name, sizeof(test_src_name), "%llx%s", random_u64(), lang->src_sfx);
839839
unsigned char test_src_path[PATH_MAX];
840840
snprintf(test_src_path, sizeof(test_src_path), "%s/%s", working_dir, test_src_name);
841841
if (generic_write_file(full_s, full_z, 0, NULL, test_src_path, NULL) < 0) {
@@ -850,6 +850,7 @@ handle_packet(
850850
xfree(full_s); full_s = NULL; full_z = 0;
851851

852852
unsigned char test_exe_name[PATH_MAX];
853+
// FIXME: random exe name?
853854
snprintf(test_exe_name, sizeof(test_exe_name), "%06d_%03d%s", req->run_id, serial, lang->exe_sfx);
854855
unsigned char test_exe_path[PATH_MAX];
855856
snprintf(test_exe_path, sizeof(test_exe_path), "%s/%s", working_dir, test_exe_name);
@@ -1031,8 +1032,9 @@ new_loop(int parallel_mode, const unsigned char *global_log_path)
10311032
path_t full_working_dir = { 0 };
10321033
struct Future *future = NULL;
10331034

1035+
random_init();
1036+
10341037
if (parallel_mode) {
1035-
random_init();
10361038
unsigned long long u64 = random_u64();
10371039
snprintf(full_working_dir, sizeof(full_working_dir), "%s/%016llx", global->compile_work_dir, u64);
10381040
if (make_dir(full_working_dir, 0) < 0) {

0 commit comments

Comments
 (0)