Re: [Bug-wget] Fwd: PATCH: bugs 20369 and 20389

2017-03-05 Thread Vijo Cherian
Thank you Darshit. Please find the patch attached to this email. This should address all your concerns about the patch. Best, Vijo. On Sat, Mar 4, 2017 at 9:26 PM, Darshit Shah wrote: > Hi Vijo, > > Could you please send the patches as an attachment generated by `git >

Re: [Bug-wget] Fwd: PATCH: bugs 20369 and 20389

2017-03-04 Thread Darshit Shah
Hi Vijo, Could you please send the patches as an attachment generated by `git format-patch`? Gmail more often than not tends to break line endings making it almost impossible to test the patches. I will currently let Eli look into the Windows and VMS compatibility for safe_{f,}open()

Re: [Bug-wget] Fwd: PATCH: bugs 20369 and 20389

2017-03-04 Thread Vijo Cherian
Thanks again Eli. Here is my revised patch, that addresses all except one of your concerns. One concern I didn't address is that of making file_exists_p() call inside fopen_stat(). That would require a lot more of code surgery than I should as I get familiar with wget code. But I can take on a

Re: [Bug-wget] Fwd: PATCH: bugs 20369 and 20389

2017-03-04 Thread Eli Zaretskii
> From: Vijo Cherian > Date: Fri, 3 Mar 2017 11:33:05 -0800 > Cc: bug-wget@gnu.org > > bool > file_exists_p (const char *filename, file_stats_t *fstats) > { > struct stat buf; > > #if defined(WINDOWS) || defined(__VMS) > return stat (filename, ) >= 0; > #else This

Re: [Bug-wget] Fwd: PATCH: bugs 20369 and 20389

2017-03-03 Thread Vijo Cherian
Sorry about the mistake in having logic around #if reversed. Here is what I meant : bool file_exists_p (const char *filename, file_stats_t *fstats) { struct stat buf; #if defined(WINDOWS) || defined(__VMS) return stat (filename, ) >= 0; #else errno = 0; if (stat (filename, ) == 0 &&

Re: [Bug-wget] Fwd: PATCH: bugs 20369 and 20389

2017-03-03 Thread Vijo Cherian
Thank you for the review, Eli Zaretskii. Will a function like below be more acceptable ? I've no way to test VMS and no ready access to development on windows : bool file_exists_p (const char *filename, file_stats_t *fstats) { struct stat buf; #if defined(WINDOWS) || defined(__VMS) errno =

Re: [Bug-wget] Fwd: PATCH: bugs 20369 and 20389

2017-03-03 Thread Eli Zaretskii
> From: Vijo Cherian > Date: Thu, 2 Mar 2017 18:47:11 -0800 > > Changes > - Bug #20369 - Safeguards against TOCTTOU > Added safe_fopen() and safe_open() that checks to makes sure the file > didn't change underneath us. > - Bug #20389 - Return error from

[Bug-wget] Fwd: PATCH: bugs 20369 and 20389

2017-03-03 Thread Vijo Cherian
Changes - Bug #20369 - Safeguards against TOCTTOU Added safe_fopen() and safe_open() that checks to makes sure the file didn't change underneath us. - Bug #20389 - Return error from file_exists_p() Added a way to return error from this file without major surgery to the callers.