[Libpst-devel] _pst_read_block_size errors

Joseph Nahmias joe at nahmias.net
Fri Apr 28 15:40:21 UTC 2006


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?

> + 		return 0;
> + 	}
>       size = rsize;
>     }

--Joe



More information about the Libpst-devel mailing list