RFC: Using fixed-length strings for version[] and osrelease[]

John-Mark Gurney gurney_j at resnet.uoregon.edu
Thu May 19 23:49:32 PDT 2005


Colin Percival wrote this message on Thu, May 19, 2005 at 16:52 -0700:
> Would anyone object to the following patch being applied?
> 
> --- newvers.sh  15 Jan 2005 13:25:41 -0000      1.68
> +++ newvers.sh  19 May 2005 23:48:21 -0000
> @@ -87,9 +87,9 @@ cat << EOF > vers.c
>  $COPYRIGHT
>  char sccspad[32 - 4 /* sizeof(sccs) */] = { '\\0' };
>  char sccs[4] = { '@', '(', '#', ')' };
> -char version[] = "${VERSION} #${v}: ${t}\\n    ${u}@${h}:${d}\\n";
> +char version[512] = "${VERSION} #${v}: ${t}\\n    ${u}@${h}:${d}\\n";
>  char ostype[] = "${TYPE}";
> -char osrelease[] = "${RELEASE}";
> +char osrelease[64] = "${RELEASE}";
>  int osreldate = ${RELDATE};
>  char kern_ident[] = "${i}";
>  EOF
> 
> The lengths 512 and 64 are chosen as being considerably more than double the
> likely lengths of these strings; on my system, these two strings are 12 bytes
> and 134 bytes long respectively.

Nope, but I would say make them just a bit larger than necessary right
now, and add the necessary CTASSERT lines to make sure we don't overflow..

I'd say no more than 256 bytes for the VERSION string, since CTASSERT will
prevent the overflow...

Though you might want to make the fixed size dependent upon the release
kernel and not for custom compiled kernels...  No point in penalizing
kernels that don't need this...

-- 
  John-Mark Gurney				Voice: +1 415 225 5579

     "All that I will do, has been done, All that I have, has not."


More information about the freebsd-arch mailing list