[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: lynx-dev Cookies and lynx2.8.2dev.24
From: |
Klaus Weide |
Subject: |
Re: lynx-dev Cookies and lynx2.8.2dev.24 |
Date: |
Sun, 25 Apr 1999 10:57:42 -0500 (CDT) |
On Sun, 25 Apr 1999 address@hidden wrote:
> > I am seeing the same problems - I have persistent cookies configured in
> > and am losing ALL cookies. Rather annoying...
>
> I just did a spot check against the binaries I built on sol - they
> save cookies. So it's not obvious to me what the problem is.
There's at least one problem in reading, not saving:
line 1996:
while(buf[i] != '\n' && i < sizeof(buf)) {
^^^^^^^^^^^
That'll always give 4 or 8 (or 16,...), since buf is a char * now.
----------------
It's questionable whether an unlimited-linelength function should be
used for reading the cookie file, since we try to limit the cookie
size. (??)
----------------
LYSafeGets() itself looks suspicious to me, although that may not
have caused the reported errors.
1) After
result = StrAllocCat(src, buffer);
the variables `src' and `result' point to the same memory. If the
FREE(src);
later is executed, the `result' pointer is invalid but is returned.
2) The interface invites errors. It seems the function always has
to be called as either
buf = LYSafeGets(NULL, fp)
or
buf = LYSafeGets(buf, fp)
(assigning immediately to the same variable tha is passed as first
argument), everything else will give memory leaks and/or invalid
pointers.
Much better to make it explicit that the buffer is modified
(reallocated etc,), by passing a `char **'. That's also more
in line with other functions (HTSACopy, HTSprintf,...).
3) If the first fgets() returns 0, the passed-in src is never
freed or reallocated, and NULL is returned. This will probably
cause memory leaks.
4) Passing `sizeof(buffer)' should be OK instead of `sizeof(buffer)-1'
according to man page.
Klaus
- Re: lynx-dev Cookies and lynx2.8.2dev.24, dickey, 1999/04/23
- Re: lynx-dev Cookies and lynx2.8.2dev.24, Larry W. Virden, 1999/04/24
- Re: lynx-dev Cookies and lynx2.8.2dev.24, dickey, 1999/04/24
- Re: lynx-dev Cookies and lynx2.8.2dev.24, dickey, 1999/04/25
- Re: lynx-dev Cookies and lynx2.8.2dev.24, dickey, 1999/04/25
- Re: lynx-dev Cookies and lynx2.8.2dev.24, dickey, 1999/04/25