[Top][All Lists]

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

[Lynx-dev] Possible bug in LYUtils.c HomeEnv function

From: Manu
Subject: [Lynx-dev] Possible bug in LYUtils.c HomeEnv function
Date: Thu, 3 Oct 2013 18:48:55 +0200

Hi Lynx developers!

I have compiled Lynx under Windows 7 and VS 2005 (I know, it is very old, forgive me) and I think I have spotted a bug in how Lynx reads stored bookmarks on Windows systems.

In the static function HomeEnv (src/LyItils.c:5140), if USE_DOS_DRIVES is defined (as it is in my case), the function performs a trial and error search through system environment variables trying to stablish a home directory.

In my case, the first if statement is satisfied:

5151     if ((result = LYGetEnv("USERPROFILE")) != 0) {
5152         HTSprintf0(&temp, "%s%sMy Documents", result, PATHSEP_STR);
5153         result = CheckDir(temp);
5154     }

And "My Documents" is hardcoded into the extracted path. This is fine for saving the bookmark file but when trying to read it, Lynx states that the file doesn't exist.

Digging into this, I have arrived to the file www/Library/Implementation/HTFile.c, method HTStat. In line 2269 a low level function is used, stat(const char*, struct stat):

2267     FREE(temp_name);
2268     } else {
2269     result = stat(filename, data);
2270 #ifdef _WINDOWS
2271     /*
2272      * Someone claims that stat() doesn't give the proper result for a
2273      * directory on Windows.
2274      */

This function always fails because the bookmarks file (i.e. c:/users/manuel/my documents/lynx_bookmarks.htm) does not exist, and it is because, from Windows Vista, "My Documents" folder no longer exists in the file system, it is a virtual folder that hides the real path (which is only "documents" by the way).

This bug can be solved by removing the hardcoded string "My Documents" and writting the bookmarks file directly into the USERPROFILE directory which, furthermore, replicates the behaviour under Linux systems. If this approach seems good, I can submit a patch to fixing it.

Moreover, the comment that function stat doesn't give the proper result in windows is wrong. In the documentation of stat (, MS states that if filename ends with slash, an errror (-1) will be returned. This can be easily fixed by checking the last character of filename prior to stat call. I can submit a patch for this also.

Best regards,

La victoria puede ser creada  -  Sun Tsu.

reply via email to

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