X-Recipient: archive-cygwin AT delorie DOT com DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CF8693858296 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com; s=default; t=1706532396; bh=njh49F8wH75Ub720pSi0CU4T2NsaBwt7YCnlwzJ4X6Q=; h=Date:To:Subject:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=jpaPoj57GX3jPm1ThbaCcTxnw5Rmp/PpUXV2FqrBOVmYIrxT0RCvQOVhUTcHGZkQ0 iOGkYaYJy+PCYRKrRHe7TjkpVhGlW/cM6YYwwb1TM8tEJHuNHARXWNJAA2r7UPBV8T kBT6SXPG27mP9zMVtr+hAGuOUYh7JpicBBvmBiNg= X-Original-To: cygwin AT cygwin DOT com Delivered-To: cygwin AT cygwin DOT com DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0FF6E3858CDA Date: Mon, 29 Jan 2024 13:46:07 +0100 To: Johnothan King Subject: Re: arc4random does not reseed after using fork() Message-ID: Mail-Followup-To: Johnothan King , "cygwin AT cygwin DOT com" References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-BeenThere: cygwin AT cygwin DOT com X-Mailman-Version: 2.1.30 Precedence: list List-Id: General Cygwin discussions and problem reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Corinna Vinschen via Cygwin Reply-To: cygwin AT cygwin DOT com Cc: Corinna Vinschen , "cygwin AT cygwin DOT com" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com Sender: "Cygwin" Hi Johnothan, On Jan 26 22:06, Johnothan King via Cygwin wrote: > 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; > } Thanks for the testcase. I fixed that for Cygwin 3.5. Please try the latest test release cygwin-3.5.0-0.617.g030a762535c1, which should be finished building in about an hour. Thanks, Corinna -- 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