summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2015-03-21 08:42:19 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2015-04-21 16:57:08 -0700
commit0887c9463fc7d36d7874e7f978df4109542f7307 (patch)
treeabaa25cfa8717e02a0b3998f811dde98b7d610f4 /include
parentb96dc999968320ad6322b50c79d847efcfcd02b2 (diff)
Import reallocarray() from OpenBSD
Wrapper for realloc() that checks for overflow when multiplying arguments together, so we don't have to add overflow checks to every single call. For documentation on usage, see: http://www.openbsd.org/cgi-bin/man.cgi/OpenBSD-current/man3/calloc.3 Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Matt Turner <mattst88@gmail.com>
Diffstat (limited to 'include')
-rw-r--r--include/dix-config.h.in3
-rw-r--r--include/os.h9
-rw-r--r--include/xorg-server.h.in3
3 files changed, 14 insertions, 1 deletions
diff --git a/include/dix-config.h.in b/include/dix-config.h.in
index 1aa77a5eb..86cf6f212 100644
--- a/include/dix-config.h.in
+++ b/include/dix-config.h.in
@@ -149,6 +149,9 @@
/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
#undef HAVE_NDIR_H
+/* Define to 1 if you have the `reallocarray' function. */
+#undef HAVE_REALLOCARRAY
+
/* Define to 1 if you have the <rpcsvc/dbm.h> header file. */
#undef HAVE_RPCSVC_DBM_H
diff --git a/include/os.h b/include/os.h
index 9d8b859d8..ffa5f3923 100644
--- a/include/os.h
+++ b/include/os.h
@@ -517,7 +517,14 @@ ddxGiveUp(enum ExitCode error);
extern _X_EXPORT int
TimeSinceLastInputEvent(void);
-/* strcasecmp.c */
+/* Function fallbacks provided by AC_REPLACE_FUNCS in configure.ac */
+
+#ifndef HAVE_REALLOCARRAY
+#define reallocarray xreallocarray
+extern _X_EXPORT void *
+reallocarray(void *optr, size_t nmemb, size_t size);
+#endif
+
#ifndef HAVE_STRCASECMP
#define strcasecmp xstrcasecmp
extern _X_EXPORT int
diff --git a/include/xorg-server.h.in b/include/xorg-server.h.in
index 4cb94875c..3152dbd68 100644
--- a/include/xorg-server.h.in
+++ b/include/xorg-server.h.in
@@ -47,6 +47,9 @@
/* Define to 1 if you have the `ffs' function. */
#undef HAVE_FFS
+/* Define to 1 if you have the `reallocarray' function. */
+#undef HAVE_REALLOCARRAY
+
/* Define to 1 if you have the `strcasecmp' function. */
#undef HAVE_STRCASECMP