
juhl at dif
Feb 17, 2004, 2:51 PM
Post #3 of 4
(783 views)
Permalink
|
|
Re: small signed/unsigned mistake in libclamav/scanners.c
[In reply to]
|
|
On Tue, 17 Feb 2004, Jesper Juhl wrote: > > > > On Tue, 17 Feb 2004, Jesper Juhl wrote: > > > > > Hi, > > > > Here's a tiny patch for a small problem in libclamav/scanners.c > > The problem is that the variable "scanned" is a signed long int * > > everywhere, and is treated as such, yet the cl_scandesc function takes an > > unsigned long int * argument and thus the signedness of the variable is > > potentially lost when it's passed on to other functions. This may or may > > not be causing any real trouble (haven't been looking that deep into it), > > but changing the argument type for scanned for the cl_scandesc() function > > to be long int * seems obviously correct to me and prevents this from ever > > becoming a real issue. > > > > Here's the small patch to make this change (against clamav-0.67) : > > > Whoops, emabaressing, I only diffed the .c file, not the clamav.h as well, > here's a corrected patch - please consider applying : > > > diff -urp clamav-0.67/libclamav/clamav.h clamav-0.67-juhl/libclamav/clamav.h > --- clamav-0.67/libclamav/clamav.h 2004-02-15 12:44:12.000000000 +0100 > +++ clamav-0.67-juhl/libclamav/clamav.h 2004-02-17 23:42:45.000000000 +0100 > @@ -113,9 +113,9 @@ struct cl_cvd { > /* file scanning */ > extern int cl_scanbuff(const char *buffer, unsigned int length, char **virname, const struct cl_node *root); > > -extern int cl_scandesc(int desc, char **virname, unsigned long int *scanned, const struct cl_node *root, const struct cl_limits *limits, int options); > +extern int cl_scandesc(int desc, char **virname, long int *scanned, const struct cl_node *root, const struct cl_limits *limits, int options); > > -extern int cl_scanfile(const char *filename, char **virname, unsigned long int *scanned, const struct cl_node *root, const struct cl_limits *limits, int options); > +extern int cl_scanfile(const char *filename, char **virname, long int *scanned, const struct cl_node *root, const struct cl_limits *limits, int options); > > /* database loading */ > extern int cl_loaddb(const char *filename, struct cl_node **root, int *virnum); > diff -urp clamav-0.67/libclamav/scanners.c clamav-0.67-juhl/libclamav/scanners.c > --- clamav-0.67/libclamav/scanners.c 2004-02-15 13:10:34.000000000 +0100 > +++ clamav-0.67-juhl/libclamav/scanners.c 2004-02-17 23:38:12.000000000 +0100 > @@ -751,14 +751,14 @@ int cli_magic_scandesc(int desc, char ** > return ret; > } > > -int cl_scandesc(int desc, char **virname, unsigned long int *scanned, const struct cl_node *root, const struct cl_limits *limits, int options) > +int cl_scandesc(int desc, char **virname, long int *scanned, const struct cl_node *root, const struct cl_limits *limits, int options) > { > int reclev = 0; > > return cli_magic_scandesc(desc, virname, scanned, root, limits, options, &reclev); > } > > -int cl_scanfile(const char *filename, char **virname, unsigned long int *scanned, const struct cl_node *root, const struct cl_limits *limits, int options) > +int cl_scanfile(const char *filename, char **virname, long int *scanned, const struct cl_node *root, const struct cl_limits *limits, int options) > { > int fd, ret; > > Yes, replying to myself again, but I just wanted to add that if there's something I've overlooked and "scanned" for some reason really should be unsigned, then ofcourse the opposite changes of the above has to be made (changing all users and the variable itself to a unsigned value). If that is the case (doesn't look like it to me), then just let me know and I'll create a patch for that instead. /Jesper Juhl
|