DragonFly submit List (threaded) for 2005-01
[
Date Prev][
Date Next]
[
Thread Prev][
Thread Next]
[
Date Index][
Thread Index]
Re: sysctl warns6 cleanup
On Sat, Jan 08, 2005 at 05:17:17PM +0100, Peter Schuller wrote:
> @@ -518,20 +519,20 @@
> case 'A':
> if (!nflag)
> printf("%s%s", name, sep);
> - printf("%.*s", len, p);
> + printf("%.*s", (int)len, p);
> return (0);
>
There should be at least a check for the value of len, to ensure that
it actually fits into an int.
> case 'I':
> if (!nflag)
> printf("%s%s", name, sep);
> fmt++;
> - val = "";
> + strcpy(val, "");
> while (len >= sizeof(int)) {
> if(*fmt == 'U')
> printf("%s%u", val, *(unsigned int *)p);
> else
> printf("%s%d", val, *(int *)p);
> - val = " ";
> + strcpy(val, " ");
> len -= sizeof(int);
> p += sizeof(int);
> }
Dont do this, please. Use a new variable or reuse sep, this are constant
strings and should stay so.
[for cases of the above]
> @@ -644,7 +645,7 @@
>
> l2 /= sizeof(int);
>
> - if (l2 < len)
> + if (l2 < (size_t)len)
> return 0;
>
> for (i = 0; i < len; i++)
Change oidfmt and sysctl_all to take the lenght as size_t instead.
Joerg
[
Date Prev][
Date Next]
[
Thread Prev][
Thread Next]
[
Date Index][
Thread Index]