URL:
  <https://savannah.gnu.org/bugs/?68136>

                 Summary: gropdf: rand() not seeded with SOURCE_DATE_EPOCH,
breaks reproducible builds
                   Group: GNU roff
               Submitter: pengzh
               Submitted: Mon 09 Mar 2026 01:24:52 PM UTC
                Category: Driver gropdf
                Severity: 3 - Normal
              Item Group: Incorrect behaviour
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Unlocked
         Planned Release: None


    _______________________________________________________

Follow-up Comments:


-------------------------------------------------------
Date: Mon 09 Mar 2026 01:24:52 PM UTC By: Peng Zhang <pengzh>
gropdf.pl uses rand() in the SubTag() function (line 5286-5292) to generate
random 6-character font subset tags. However, srand() is never initialized
with a deterministic value, causing each build to produce different PDF binary
output even when all inputs are identical.

groff already partially supports reproducible builds by using
SOURCE_DATE_EPOCH for PDF date metadata (PDFDate function), but the random
number generator is not seeded accordingly.

The SubTag() function was introduced in commit 77fb2e809 as part of the font
subsetting feature. This issue does not affect groff 1.23.x.

Root cause (src/devices/gropdf/gropdf.pl):

sub SubTag
{
    my $res;
    foreach (1..6)
    {
        $res.=chr(int((rand(26)))+65);
    }
    return($res.'+');
}

Proposed fix - add srand() initialization near the top of gropdf.pl:

# Initialize random seed for reproducible builds.
if (defined($ENV{SOURCE_DATE_EPOCH})) {
    srand($ENV{SOURCE_DATE_EPOCH});
} else {
    srand();
}

Environment:
- groff version: 1.24.0
- Discovered during Yocto Project reproducible build testing (oe-selftest)









    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?68136>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/

Attachment: signature.asc
Description: PGP signature

Reply via email to