summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordoug <>2014-10-22 05:19:27 +0000
committerdoug <>2014-10-22 05:19:27 +0000
commit5a6d7fd5a10b0ad084948463b25822d91091b325 (patch)
tree47cdaee64f407c6e04010fbc7347f1b262d27be6
parentc95a384eee0578c645789ea3fd210c812b655803 (diff)
downloadopenbsd-5a6d7fd5a10b0ad084948463b25822d91091b325.tar.gz
openbsd-5a6d7fd5a10b0ad084948463b25822d91091b325.tar.bz2
openbsd-5a6d7fd5a10b0ad084948463b25822d91091b325.zip
Avoid writing in second person in malloc.3
ok deraadt@
-rw-r--r--src/lib/libc/stdlib/malloc.325
1 files changed, 12 insertions, 13 deletions
diff --git a/src/lib/libc/stdlib/malloc.3 b/src/lib/libc/stdlib/malloc.3
index 8305b14d35..caf1da2207 100644
--- a/src/lib/libc/stdlib/malloc.3
+++ b/src/lib/libc/stdlib/malloc.3
@@ -30,9 +30,9 @@
30.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31.\" SUCH DAMAGE. 31.\" SUCH DAMAGE.
32.\" 32.\"
33.\" $OpenBSD: malloc.3,v 1.81 2014/10/20 19:35:23 schwarze Exp $ 33.\" $OpenBSD: malloc.3,v 1.82 2014/10/22 05:19:27 doug Exp $
34.\" 34.\"
35.Dd $Mdocdate: October 20 2014 $ 35.Dd $Mdocdate: October 22 2014 $
36.Dt MALLOC 3 36.Dt MALLOC 3
37.Os 37.Os
38.Sh NAME 38.Sh NAME
@@ -195,7 +195,7 @@ Consider
195.Fn calloc 195.Fn calloc
196or the extension 196or the extension
197.Fn reallocarray 197.Fn reallocarray
198when you have multiplication in the 198when there is multiplication in the
199.Fa size 199.Fa size
200argument of 200argument of
201.Fn malloc 201.Fn malloc
@@ -648,26 +648,25 @@ When using
648.Fn malloc , 648.Fn malloc ,
649be wary of signed integer and 649be wary of signed integer and
650.Vt size_t 650.Vt size_t
651overflow especially when you 651overflow especially when there is multiplication in the
652have multiplication in the
653.Fa size 652.Fa size
654argument. 653argument.
655.Pp 654.Pp
656Signed integer overflow will cause undefined behavior which compilers 655Signed integer overflow will cause undefined behavior which compilers
657typically handle by wrapping back around to negative numbers. 656typically handle by wrapping back around to negative numbers.
658Depending on the input, this can result in allocating more or less 657Depending on the input, this can result in allocating more or less
659memory than you intended. 658memory than intended.
660.Pp 659.Pp
661An unsigned overflow has defined behavior which will wrap back around and you 660An unsigned overflow has defined behavior which will wrap back around and
662will receive less memory than you intended. 661return less memory than intended.
663.Pp 662.Pp
664A signed or unsigned integer overflow is a 663A signed or unsigned integer overflow is a
665.Em security 664.Em security
666risk if you end up allocating less memory than you intended. 665risk if less memory is returned than intended.
667Your code may corrupt the heap by writing beyond the memory that you 666Subsequent code may corrupt the heap by writing beyond the memory that was
668were allocated. 667allocated.
669An attacker may be able to leverage this heap corruption to convince your 668An attacker may be able to leverage this heap corruption to execute arbitrary
670program to execute arbitrary code. 669code.
671.Pp 670.Pp
672Consider using 671Consider using
673.Fn calloc 672.Fn calloc