calloc in nnrpd/perl.c

Russ Allbery rra at stanford.edu
Sun Mar 3 17:55:00 UTC 2002


Jeffrey M Vinocur <jeff at litech.org> writes:

> There are a couple uses of calloc() in nnrpd/perl.c -- I suppose they
> should be xcalloc?  (Actually, one of them doesn't even need to be
> zero'd.)

Yup.

> Hmm.  I don't know why there's an itoa() being defined in that file in
> the first place -- it seems like sprintf would do as well -- but by my
> reading of strcat, that shouldn't even work, since the dst array is not
> large enough to hold the result of the concatenation.

That code is bizarre.

I believe that itoa will explode with any number larger than 9, which is
convenient since I don't think it will ever be called with a number larger
than 9.  But that code and everything related to it really needs to be
rethought from scratch.

The first element of the array that's being constructed is a string
representation of the number of items in the array, which is only used as
an argument to atoi in the caller to get the array length.  It looks like
someone really wanted a vector, which we now have in libinn.  That would
require some fiddling in perm.c, but I think it's probably the clean
solution.

-- 
Russ Allbery (rra at stanford.edu)             <http://www.eyrie.org/~eagle/>


More information about the inn-workers mailing list