1
From 2f5c1750558fe64bac361f52d6827ab1bcfe52bc Mon Sep 17 00:00:00 2001
2
From: =?utf8?q?Ond=C5=99ej=20B=C3=ADlka?= <neleai@seznam.cz>
3
Date: Sat, 11 Jul 2015 17:44:10 +0200
4
Subject: [PATCH] Handle overflow in __hcreate_r
8
As in bugzilla entry there is overflow in hsearch when looking for prime
9
number as SIZE_MAX - 1 is divisible by 5. We fix that by rejecting large
10
inputs before looking for prime.
12
* misc/hsearch_r.c (__hcreate_r): Handle overflow.
14
[Note: patch differs from upstream commit in that the entries in
15
the Changelog were dropped to avoid patch conflicts. -- sbeattie]
17
ChangeLog | 10 ++++++++++
18
misc/hsearch_r.c | 9 ++++++++-
19
2 files changed, 18 insertions(+), 1 deletions(-)
21
diff --git a/misc/hsearch_r.c b/misc/hsearch_r.c
22
index 9f55e84..559df29 100644
23
--- a/misc/hsearch_r.c
24
+++ b/misc/hsearch_r.c
33
/* [Aho,Sethi,Ullman] Compilers: Principles, Techniques and Tools, 1986
34
@@ -73,6 +73,13 @@ __hcreate_r (nel, htab)
38
+ if (nel >= SIZE_MAX / sizeof (_ENTRY))
40
+ __set_errno (ENOMEM);
45
/* There is still another table active. Return with error. */
46
if (htab->table != NULL)