X-Recipient: archive-cygwin AT delorie DOT com DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AC9443858297 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com; s=default; t=1706306852; bh=jONhHg+VBC5xNmoTMKA9mKGzZEf99W8SODq2qzOHvfk=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=m30253EOf0l6mvvrkLnPGUYHJUIqE1DNu+bxnr45srrK66S271Mz0e4h509U/S3PL oeh141eugUXWkHPMXvQlnePXBt+lpHwHH77SkTw03hnjUf8HlZ9c0nWctR0Uy8Ev/J rIdtHXXGktQSm4KLCG/Zcd2Pv3PaEu3cwmXtLjiY= X-Original-To: cygwin AT cygwin DOT com Delivered-To: cygwin AT cygwin DOT com DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C5C7A3858C2A ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C5C7A3858C2A ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706306795; cv=none; b=r3/ld58t3OOixYYKQ3TAYwIFvGyUCO7+fBGEYKUUYAajTNQBF1b7See8yRomFRj9DScVa+AymMdOIs4Z0FRFuBsKliGGwClcv52Yzg8euRaOQR1DvI+acOsJiy+A4BGVUrSvzB7na1GAgHRN1vzg9Q2auLpkNXfjrYygVmatLjI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706306795; c=relaxed/simple; bh=4b1fQqXQpxa3q6t+PB2QiwPxLkFRtRY+QMbfeDi2JZk=; h=DKIM-Signature:Date:To:From:Subject:Message-ID:MIME-Version; b=HVKh6Lc77ogL4S0wUC/nnClA+X7GzGBmFhH7yN8pXalgx0d9vxgvOTRfhgzSdotO2qis4tnEcbsQtZbsURHQg78OpBgAU2D1dAJB/hQQjYl5k+4Ps1J1m4Xc3sBpuhrIb022IuMOmAqDdGZFfzlG95Fj+JTxwcre2GwymtPB5MY= ARC-Authentication-Results: i=1; server2.sourceware.org Date: Fri, 26 Jan 2024 22:06:15 +0000 To: "cygwin AT cygwin DOT com" Subject: arc4random does not reseed after using fork() Message-ID: Feedback-ID: 1750573:user:proton MIME-Version: 1.0 X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: cygwin AT cygwin DOT com X-Mailman-Version: 2.1.30 List-Id: General Cygwin discussions and problem reports List-Archive: List-Post: List-Help: List-Subscribe: , From: Johnothan King via Cygwin Reply-To: Johnothan King Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "Cygwin" Hello, While testing ksh93u+m's recently added SRANDOM variable[1], I have discovered a bug in Cygwin's arc4random function. After using fork(), arc4random does not reseed itself, which causes the results to become predictable[2]. Below is a test case C program exhibiting the bug: #include #include #include #include int main(void) { pid_t child = fork(); if(child==0) { printf("%u %u %u\n", arc4random(), arc4random(), arc4random()); return 0; } else if(child==-1) return 1; waitpid(child, NULL, 0); printf("%u %u %u\n", arc4random(), arc4random(), arc4random()); return 0; } Cygwin output: 3249037162 736770761 3917821637 3249037162 736770761 3917821637 Linux output (using glibc's arc4random): 746998953 2346785455 2324882761 2868775179 924299332 3954938398 [1]: https://github.com/ksh93/ksh/commit/00b296c [2]: https://github.com/ksh93/ksh/issues/711 - Johnothan King -- Problem reports: https://cygwin.com/problems.html FAQ: https://cygwin.com/faq/ Documentation: https://cygwin.com/docs.html Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple