lynx-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Lynx-dev] Small patches for lynx2.8.9dev.16


From: patakuti
Subject: Re: [Lynx-dev] Small patches for lynx2.8.9dev.16
Date: Sun, 27 Aug 2017 20:58:47 -0700 (PDT)

Thanks for your useful comment.
I agree with your comment regarding DOS like file systems.

> bug produced when the coding is posix centric.  It remains unclear
> to me why stat is used instead of access.  Something like:
>   access(dst, F_OK) != 0
> is faster than having to compute stat for a file on windows or dos
> AFAIK.  Do not get me wrong, for this application it will not really
> matter.

On the other hand, I'm not sure which function we should use for checking file 
existence.
According to the following site, access() is used in "Compliant Solution 
(POSIX)", but _access_s() is used in "Compliant Solution (Windows)."  There 
seems to be some reason not to use access() on Windows.
https://www.securecoding.cert.org/confluence/display/c/FIO10-C.+Take+care+when+using+the+rename%28%29+function

So I decided not to use access(), but it's not a strong opinion.

Thanks, 

Takeshi Hataguchi

From: Juan Manuel Guerrero <address@hidden>
Subject: Re: [Lynx-dev] Small patches for lynx2.8.9dev.16
Date: Sun, 27 Aug 2017 22:19:55 +0200

> lynx.patch_for_289dev16-3 discribes a really serious issue but not
> only for windows but also for all other DOS like file systems too,
> thus I would suggest something like the small fix shown below.  It
> shows a modification of the original patch.  It is is a classical
> bug produced when the coding is posix centric.  It remains unclear
> to me why stat is used instead of access.  Something like:
>   access(dst, F_OK) != 0
> is faster than having to compute stat for a file on windows or dos
> AFAIK.  Do not get me wrong, for this application it will not really
> matter.
> 
> Regards,
> Juan M. Guerrero
> 
> 
> 
> 
> 
> diff -aprNU5 lynx2.8.9dev.16.orig/src/LYUtils.c lynx2.8.9dev.16/src/LYUtils.c
> --- lynx2.8.9dev.16.orig/src/LYUtils.c        2017-08-27 00:17:50 +0000
> +++ lynx2.8.9dev.16/src/LYUtils.c     2017-08-27 10:19:32 +0000
> @@ -7102,13 +7102,13 @@ void LYAddHtmlSep0(char *path)
>   * Rename a file
>   */
>  int LYRenameFile(char *src,
>               char *dst)
>  {
> -#ifdef _WINDOWS
> +#ifdef DOSPATH
>      /*
> -     * If dest_file exists prior to calling rename(), rename() will fail on 
> Windows platforms.
> +     * If dest_file exists prior to calling rename(), rename() will fail on 
> Windows and DOS platforms.
>       * 
> https://www.securecoding.cert.org/confluence/display/c/FIO10-C.+Take+care+when+using+the+rename%28%29+function
>       */
>      struct stat st;
>      if (stat(dst, &st) == 0) {
>       unlink(dst);
> 
> _______________________________________________
> Lynx-dev mailing list
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/lynx-dev



reply via email to

[Prev in Thread] Current Thread [Next in Thread]