[PATCH] Add support for atoll on HP-UX

Elia Pinto gitter.spiros at gmail.com
Wed Aug 10 09:51:52 MDT 2011

The patch for CVE-2011-2522 uses atoll()
but HP-UX 11.00/PA, 11.11/PA, and 11.23/PA
do not provide this function. Add a atoll
replacement function for HP-UX.
 lib/replace/README        |    1 +
 lib/replace/libreplace.m4 |    2 +-
 lib/replace/replace.c     |    7 +++++++
 lib/replace/replace.h     |    5 +++++
 lib/replace/wscript       |    2 +-
 source3/configure.in      |    1 +
 source3/wscript           |    2 +-
 7 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/lib/replace/README b/lib/replace/README
index bf4e67f..71e7f60 100644
--- a/lib/replace/README
+++ b/lib/replace/README
@@ -72,6 +72,7 @@ link
diff --git a/lib/replace/libreplace.m4 b/lib/replace/libreplace.m4
index 808d5d1..f11401a 100644
--- a/lib/replace/libreplace.m4
+++ b/lib/replace/libreplace.m4
@@ -110,7 +110,7 @@ AC_CHECK_FUNCS(seteuid setresuid setegid setresgid chroot bzero strerror strerro
 AC_CHECK_FUNCS(vsyslog setlinebuf mktime ftruncate chsize rename)
 AC_CHECK_FUNCS(waitpid wait4 strlcpy strlcat initgroups memmove strdup)
 AC_CHECK_FUNCS(pread pwrite strndup strcasestr strtok_r mkdtemp dup2 dprintf vdprintf)
-AC_CHECK_FUNCS(isatty chown lchown link readlink symlink realpath)
+AC_CHECK_FUNCS(isatty chown lchown link readlink symlink realpath atoll)
 	# if we didn't find it, look in librt (Solaris hides it there...)
 	AC_CHECK_LIB(rt, fdatasync,
diff --git a/lib/replace/replace.c b/lib/replace/replace.c
index d9a96ff..6197a0a 100644
--- a/lib/replace/replace.c
+++ b/lib/replace/replace.c
@@ -728,6 +728,13 @@ char *rep_realpath(const char *path, char *resolved_path)
+#ifndef HAVE_ATOLL
+/* Convert a string to a long long int.  */
+long long int atoll (const char *nptr)
+  return strtoll (nptr, (char **) NULL, 10);
 #ifndef HAVE_MEMMEM
 void *rep_memmem(const void *haystack, size_t haystacklen,
diff --git a/lib/replace/replace.h b/lib/replace/replace.h
index c081f23..c5f76b8 100644
--- a/lib/replace/replace.h
+++ b/lib/replace/replace.h
@@ -266,6 +266,11 @@ int rep_symlink(const char *oldpath, const char *newpath);
 char *rep_realpath(const char *path, char *resolved_path);
+#ifndef HAVE_ATOLL
+#define atoll rep_atoll
+long long int rep_atoll(const char *nptr);
 #ifndef HAVE_LCHOWN
 #define lchown rep_lchown
 int rep_lchown(const char *fname,uid_t uid,gid_t gid);
diff --git a/lib/replace/wscript b/lib/replace/wscript
index c24d6e7..895faf3 100644
--- a/lib/replace/wscript
+++ b/lib/replace/wscript
@@ -165,7 +165,7 @@ def configure(conf):
     conf.CHECK_FUNCS('ftruncate chsize rename waitpid wait4 strlcpy strlcat')
     conf.CHECK_FUNCS('initgroups pread pwrite strndup strcasestr')
     conf.CHECK_FUNCS('strtok_r mkdtemp dup2 dprintf vdprintf isatty chown lchown')
-    conf.CHECK_FUNCS('link readlink symlink realpath snprintf vsnprintf')
+    conf.CHECK_FUNCS('link readlink symlink realpath atoll snprintf vsnprintf')
     conf.CHECK_FUNCS('asprintf vasprintf setenv unsetenv strnlen strtoull __strtoull')
     conf.CHECK_FUNCS('strtouq strtoll __strtoll strtoq')
     #Some OS (ie. freebsd) return EINVAL if the convertion could not be done, it's not what we expect
diff --git a/source3/configure.in b/source3/configure.in
index af8285f..618835f 100644
--- a/source3/configure.in
+++ b/source3/configure.in
@@ -1102,6 +1102,7 @@ AC_CHECK_FUNCS(shmget shm_open)
 AC_CHECK_FUNCS(gettext dgettext)
 AC_CHECK_FUNCS(bindtextdomain textdomain bind_textdomain_codeset)
 # Find a method of generating a stack trace
 AC_CHECK_HEADERS(execinfo.h libexc.h libunwind.h)
diff --git a/source3/wscript b/source3/wscript
index f7c12a8..c9a38e5 100644
--- a/source3/wscript
+++ b/source3/wscript
@@ -161,7 +161,7 @@ def configure(conf):
     conf.CHECK_FUNCS('memalign posix_memalign hstrerror')
     conf.CHECK_FUNCS_IN('shm_open', 'rt', checklibc=True)
-    conf.CHECK_FUNCS('gettext dgettext bindtextdomain textdomain bind_textdomain_codeset')
+    conf.CHECK_FUNCS('gettext dgettext bindtextdomain textdomain bind_textdomain_codeset atoll')
     #FIXME: for some reason this one still fails
     conf.CHECK_FUNCS_IN('yp_get_default_domain', 'nsl')
     conf.CHECK_FUNCS_IN('dn_expand _dn_expand __dn_expand', 'resolv')

More information about the samba-technical mailing list