[Libpst-devel] _pst_read_block_size errors

Joseph Nahmias joe at nahmias.net
Fri Apr 28 20:55:41 UTC 2006


On Fri, Apr 28, 2006 at 09:51:10PM +0100, Nigel Horne wrote:
> Joseph Nahmias wrote:
> >Nigel,
> >
> >On Wed, Apr 26, 2006 at 01:40:24PM +0100, Nigel Horne wrote:
> >
> >>In _pst_read_block_size if the number of bytes read is small (typically 0)
> >>the software reads uninitialised values because it does things such as
> >>read buf[0], even though no data has been read into it.
> >
> >
> >I agree that this could lead to problems.
> >
> >
> >>Here's the proposed fix:
> >>
> >>*** Olibpst.c	Wed Apr 26 13:35:51 2006
> >>--- libpst.c	Wed Apr 26 13:37:17 2006
> >>***************
> >>*** 3856,3861 ****
> >>--- 3856,3866 ----
> >>     } else {
> >>       DEBUG_WARN(("I can't tell why it failed\n"));
> >>     }
> >>+ 	if(rsize <= 2) {
> >>+ 		fseek(pf->fp, fpos, SEEK_SET);
> >>+ 		*buf = '\0';
> >
> >
> >This seems like a memory leak to me.  We should be freeing *buf
> >and then setting it to NULL.  Also, I would put this outside
> >the if (rsize != size) block.  If, for whatever reason, size were 1 this
> >would still crash.  Agreed?
> 
> I sent a fix to my patch a couple of days ago, replacing *buf = '\0'
> with **buf = '\0'. Did you not get it?

I noticed it only after I sent this mail.  However, I still think we
should be freeing *buf... Thoughts?



More information about the Libpst-devel mailing list