Bug 689218 - suspicious patch making bookmark permissions compatible with IsOurFile()
Summary: suspicious patch making bookmark permissions compatible with IsOurFile()
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Fedora
Classification: Fedora
Component: lynx
Version: rawhide
Hardware: All
OS: Linux
low
low
Target Milestone: ---
Assignee: Thomas E. Dickey
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On: 486070
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-03-20 12:02 UTC by Kamil Dudka
Modified: 2011-03-20 17:14 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of: 486070
Environment:
Last Closed: 2011-03-20 17:14:38 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Kamil Dudka 2011-03-20 12:02:48 UTC
+++ This bug was initially created as a clone of Bug #486070 +++

--- Additional comment from kdudka on 2010-01-06 12:41:42 CET ---

Created attachment 381962 [details]
gdb trace

Note it does not happen when running lynx as root.

I am able to get over the bug using the following patch:

--- a/src/LYUtils.c
+++ b/src/LYUtils.c
@@ -5849,8 +5849,8 @@ static FILE *OpenHiddenFile(const char *name, const char *mode)
     } else
 #endif
     if (*mode == 'a') {
-       if (IsOurFile(name)
-           && chmod(name, HIDE_CHMOD) == 0)
+       if (/*IsOurFile(name)
+           &&*/ chmod(name, HIDE_CHMOD) == 0)
            fp = fopen(name, mode);
        else if (lstat(name, &data) != 0)
            fp = OpenHiddenFile(name, binary ? BIN_W : TXT_W);

--- Additional comment from dickey on 2010-01-13 02:37:44 CET ---

Created attachment 383388 [details]
diff to make bookmark permissions compatible with IsOurFile()

Comment 1 Kamil Dudka 2011-03-20 12:07:02 UTC
Thomas, while analyzing the patches inside lynx-2.8.7-6.fc15, I discovered something odd in the patch above.  Could you please have a look at the following code?

mode = ((stat_buf.st_mode & HIDE_CHMOD) | 0600);	/* make it writable */

... means the same as:

mode = 0600;

That is, the value of 'mode is' independent of stat_buf.st_mode.  Is that intended?

Comment 2 Thomas E. Dickey 2011-03-20 16:19:58 UTC
yes - it's redundant to "OR" HIDE_CHMOD (which is 0600) and the actual 0600,
but if HIDE_CHMOD were more lax, e.g., 0640, then the result could inherit
a read-bit from stat_buf.st_mode

So (aside from a qualm about the redundancy), it seems to be doing what
I intended, which was to use HIDE_CHMOD to select only the bits that
correspond to a "hidden" file, and then to add back the bits that let
lynx read/write the file.

I'd have used symbols from <sys/stat.h>, however those (especially when
I wrote that 10-12 years ago) have portability issues.

Comment 3 Kamil Dudka 2011-03-20 17:14:38 UTC
Thanks for clarifying that.  So the construction makes sense in case you changed the definition of HIDE_CHMOD in <LYUtils.h> to something else in the future.  Then we can probably close the bug.


Note You need to log in before you can comment on or make changes to this bug.