[Libpst-devel] _pst_read_block_size errors

Nigel Horne njh at bandsman.co.uk
Fri Apr 28 20:51:10 UTC 2006


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?

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

-Nigel

-- 
Nigel Horne. Arranger, Adjudicator, Band Trainer, Composer, Tutor, 
Typesetter.
NJH Music, Barnsley, UK.  ICQ#20252325
njh at bandsman.co.uk http://www.bandsman.co.uk
-------------- next part --------------
A non-text attachment was scrubbed...
Name: njh.vcf
Type: text/x-vcard
Size: 181 bytes
Desc: not available
Url : http://lists.alioth.debian.org/pipermail/libpst-devel/attachments/20060428/b74d1004/njh.vcf


More information about the Libpst-devel mailing list