lynx-dev
[Top][All Lists]
Advanced

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

Re: lynx-dev Cookies and lynx2.8.2dev.24


From: dickey
Subject: Re: lynx-dev Cookies and lynx2.8.2dev.24
Date: Sun, 25 Apr 1999 14:26:42 -0400 (EDT)

> 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)) { 
yes (I didn't see that):
          while(buf[i] != '\n' && buf[i] != 0) { 
>                                     ^^^^^^^ 
I assume that's the bug that is stopping cookies from working.

> 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. 

yes (my error) - there should be an assignment to src later (I guess I
need more sleep).
  
> 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. 
that's the way it's designed, yes (I think I was consistent)
  
> 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. 
yes.
  
>    Klaus 
>  
>  
>  
> 


-- 
Thomas E. Dickey
address@hidden
http://www.clark.net/pub/dickey

reply via email to

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