[nasm:master] omit input filename from COFF output when --reproducible

nasm-bot for Viktor Szakats commit at vsz.me
Mon Nov 7 17:12:26 PST 2022


Commit-ID:  e1423b057304b4fc8af7d1fc048ccaa5cc66a2bd
Gitweb:     http://repo.or.cz/w/nasm.git?a=commitdiff;h=e1423b057304b4fc8af7d1fc048ccaa5cc66a2bd
Author:     Viktor Szakats <commit at vsz.me>
AuthorDate: Tue, 12 Jul 2022 06:07:48 +0000
Committer:  Viktor Szakats <commit at vsz.me>
CommitDate: Tue, 12 Jul 2022 06:07:53 +0000

omit input filename from COFF output when --reproducible

Before this patch, COFF output always contained the first 18 bytes of the
input filename. This breaks reproducibility and may also leak sensitive
data to objects (esp. with input filenames with absolute paths.)

This patch makes this output respect the --reproducible option, and omits
the input filename from the COFF output, when set.


---
 output/outcoff.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/output/outcoff.c b/output/outcoff.c
index e505fe60..a9e3bf82 100644
--- a/output/outcoff.c
+++ b/output/outcoff.c
@@ -1275,7 +1275,10 @@ static void coff_write_symbols(void)
      * The `.file' record, and the file name auxiliary record.
      */
     coff_symbol(".file", 0L, 0L, -2, 0, 0x67, 1);
-    strncpy(filename, inname, 18);
+    if (reproducible)
+        memset(filename, 0, 18);
+    else
+        strncpy(filename, inname, 18);
     nasm_write(filename, 18, ofile);
 
     /*


More information about the Nasm-commits mailing list