Merge branch 'deterministic_bitfile_builds2' of github.com:n-hutton/proxmark3 into deterministic_bitfile_builds2

This commit is contained in:
n-hutton 2025-02-20 14:40:43 +00:00
commit 46506f04ae

View file

@ -18,6 +18,8 @@
#include <stdint.h> #include <stdint.h>
#include <stdbool.h> #include <stdbool.h>
#include <inttypes.h> #include <inttypes.h>
#include <sys/stat.h>
#include "time.h"
#include "fpga.h" #include "fpga.h"
#include "lz4hc.h" #include "lz4hc.h"
@ -380,30 +382,22 @@ static int FpgaGatherVersion(FILE *infile, char *infile_name, char *dst, int len
strncat(dst, tempstr, len - strlen(dst) - 1); strncat(dst, tempstr, len - strlen(dst) - 1);
} }
strncat(dst, " ", len - strlen(dst) - 1); // Get file statistics to extract date and time via file timestamp
if (bitparse_find_section(infile, 'c', &fpga_info_len)) { int fd = fileno(infile);
for (uint32_t i = 0; i < fpga_info_len; i++) { struct stat fileStat;
char c = (char)fgetc(infile);
if (i < sizeof(tempstr)) { if (fstat(fd, &fileStat) == 0) {
if (c == '/') c = '-'; struct tm *modTime = localtime(&fileStat.st_mtime);
if (c == ' ') c = '0';
tempstr[i] = c;
} char timeBuf[64];
} snprintf(timeBuf, sizeof(timeBuf), " %02d-%02d-%04d %02d:%02d:%02d",
strncat(dst, tempstr, len - strlen(dst) - 1); modTime->tm_mday, modTime->tm_mon + 1, modTime->tm_year + 1900,
modTime->tm_hour, modTime->tm_min, modTime->tm_sec);
strncat(dst, timeBuf, len - strlen(dst) - 1);
} }
if (bitparse_find_section(infile, 'd', &fpga_info_len)) {
strncat(dst, " ", len - strlen(dst) - 1);
for (uint32_t i = 0; i < fpga_info_len; i++) {
char c = (char)fgetc(infile);
if (i < sizeof(tempstr)) {
if (c == ' ') c = '0';
tempstr[i] = c;
}
}
strncat(dst, tempstr, len - strlen(dst) - 1);
}
return 0; return 0;
} }