SFT-6948: fixed add-secrets portability, removed unnecessary error walling
What changed, and why it matters
This is a small build-tool fix in the factory/secrets-injection utility used during Passport device manufacturing. It replaces a non-portable type name (`ulong`) with the standard C type (`unsigned long`) and removes a compiler flag that was suppressing the resulting error. There is no direct evidence this change fixes an exploitable security vulnerability; it appears to be a portability/correctness cleanup that lets the tool compile cleanly across build environments.
No urgent action required. Treat as a normal build hygiene commit. If reviewing the broader add-secrets tooling, audit the helper for safe file-size handling, null termination, and least-privilege access to manufacturing secrets, but those concerns are outside the scope of this specific diff.
Security signals we found
Type portability fix in a secrets-injection build tool
Removal of a compiler warning suppression that masked a type error
No change to runtime logic, buffer size, or secret handling observed
Evidence from the diff
The commit changes sizeof(ulong) to sizeof(unsigned long) in add-secrets.c, a host-side manufacturing helper that reads a file into a freshly allocated buffer. ulong is not a standard C type (it is a legacy/Unix typedef often available via <sys/types.h> but not guaranteed), so the previous code could fail to compile on some toolchains. The accompanying nix change removes -Wno-error=int-conversion, which had been downgrading the compile failure to a warning. The buffer allocation adds one extra machine word to the file size, likely for trailing metadata or alignment. The change does not alter allocation size semantics (both forms evaluate to the same width on the platforms where ulong exists), but it makes the build deterministic and standards-compliant.
Changed components
ports/stm32/boards/Passport/tools/add-secrets/add-secrets.cnix/add-secrets.nixInspect captured patch +1 / −2
diff --git a/nix/add-secrets.nix b/nix/add-secrets.nix
index 104b459..d849ccc 100644
--- a/nix/add-secrets.nix
+++ b/nix/add-secrets.nix
@@ -10,7 +10,6 @@
version = "0.1.0";
src = self + "/ports/stm32/boards/Passport";
dontConfigure = true;
- NIX_CFLAGS_COMPILE = "-Wno-error=int-conversion";
buildPhase = ''
runHook preBuild
diff --git a/ports/stm32/boards/Passport/tools/add-secrets/add-secrets.c b/ports/stm32/boards/Passport/tools/add-secrets/add-secrets.c
index d9ef671..9c751b5 100644
--- a/ports/stm32/boards/Passport/tools/add-secrets/add-secrets.c
+++ b/ports/stm32/boards/Passport/tools/add-secrets/add-secrets.c
@@ -62,7 +62,7 @@ static int read_file(char* path, uint8_t** buffer, size_t* size) {
}
stat(path, &info);
- *buffer = (uint8_t*)calloc(1, info.st_size + sizeof(ulong));
+ *buffer = (uint8_t*)calloc(1, info.st_size + sizeof(unsigned long));
if (*buffer == NULL) {
printf("insufficient memory\n");
return -1;
Why this scored 18/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.