[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: a bug in svn_fs_base__unparse_representation_skel?

From: Philip Martin <philip_at_codematters.co.uk>
Date: 2005-12-09 02:00:06 CET

Mary Jane Lemur <mjlemur@gmail.com> writes:

> i'm looking in libsvn_fs_base/util/fs_skels.c, line 1038.
> the code seems to be duplicating the rep->checksum array in memory by
> calling svn_fs_base__mem_atom. i understand that it's passing
> rep->checksum as the 'data' argument, but for the 'length' argument
> its passing
> APR_MD5_DIGESTSIZE / sizeof (*(rep->checksum)
> isnt this wrong? if we're on a system where (unsigned char) is 2
> bytes,

The ISO C standard defines sizeof char to be 1. As far as I know
systems that are "unusual", things like 32 bit DSP's, usually use
something like sizeof char == sizeof int == 1. Do you know of any
systems where sizeof char is not 1? I'd expect loads of code to fail
on any such non-standard system.

> then dont we want to allocate a memory space thats twice as big?
> instead of dividing, shouldnt it be multiplying by the sizeof()?
> like
> APR_MD5_DIGESTSIZE * sizeof (*(rep->checksum)
> i'm guessing that this bug hasnt been noticed because every system so
> far has a 1-byte unsigned char, so we're dividing APR_MD5_DIGESTSIZE
> by 1, which works out ok. just lucky, mebbe?

That said the code does look odd; I think it should be either
sizeof(rep->checksum) or APR_MD5_DIGESTSIZE without any multiplication
or division.

Philip Martin
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Fri Dec 9 02:01:11 2005

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.