improve wording in alloca

2015-01-16 Thread Ted Unangst
Improve wording in alloca.
1. it's not a bug; it's a caveat.
2. slightly unsafe gives me the willies.
3. nobody knows what large unbounded allocations are.
4. one .Xr to malloc should suffice

Index: alloca.3
===
RCS file: /cvs/src/lib/libc/stdlib/alloca.3,v
retrieving revision 1.13
diff -u -p -r1.13 alloca.3
--- alloca.35 Jun 2013 03:39:23 -   1.13
+++ alloca.316 Jan 2015 22:26:15 -
@@ -51,9 +51,7 @@ function returns a pointer to the beginn
 .Sh SEE ALSO
 .Xr pagesize 1 ,
 .Xr brk 2 ,
-.Xr calloc 3 ,
-.Xr malloc 3 ,
-.Xr realloc 3
+.Xr malloc 3
 .\ .Sh HISTORY
 .\ The
 .\ .Fn alloca
@@ -62,10 +60,10 @@ function returns a pointer to the beginn
 .\ The function appeared in 32v, pwb and pwb.2 and in 3bsd 4bsd
 .\ The first man page (or link to a man page that I can find at the
 .\ moment is 4.3...
-.Sh BUGS
+.Sh CAVEATS
 The
 .Fn alloca
-function is slightly unsafe because it cannot ensure that the pointer
+function is unsafe because it cannot ensure that the pointer
 returned points to a valid and usable block of memory.
 The allocation made may exceed the bounds of the stack, or even go
 further into other objects in memory, and
@@ -73,4 +71,4 @@ further into other objects in memory, an
 cannot determine such an error.
 Avoid
 .Fn alloca
-with large unbounded allocations.
+when possible.



Re: improve wording in alloca

2015-01-16 Thread Theo de Raadt
 @@ -51,9 +51,7 @@ function returns a pointer to the beginn
  .Sh SEE ALSO
  .Xr pagesize 1 ,
  .Xr brk 2 ,
 -.Xr calloc 3 ,
 -.Xr malloc 3 ,
 -.Xr realloc 3
 +.Xr malloc 3

This is good.  It has no relationship to callor or realloc.

 -.Sh BUGS
 +.Sh CAVEATS

OK.

  The
  .Fn alloca
 -function is slightly unsafe because it cannot ensure that the pointer
 +function is unsafe because it cannot ensure that the pointer

OK

 @@ -73,4 +71,4 @@ further into other objects in memory, an
  cannot determine such an error.
  Avoid
  .Fn alloca
 -with large unbounded allocations.
 +when possible.

I wrote it this way to provide even greater caution.  It makes
people think hmm, is my allocation size known.  Then they run
away screaming.   I think my wording has more impact.