Blob Blame History Raw
diff -up nss-pam-ldapd-0.7.17/nslcd/common.c.overflow nss-pam-ldapd-0.7.17/nslcd/common.c
--- nss-pam-ldapd-0.7.17/nslcd/common.c.overflow	2012-09-09 19:51:44.254856507 +0200
+++ nss-pam-ldapd-0.7.17/nslcd/common.c	2012-09-09 19:52:32.602252083 +0200
@@ -148,19 +148,25 @@ int read_address(TFILE *fp,char *addr,in
   return 0;
 }
 
-#ifdef WANT_STRTOUI
+
 /* provide a strtoui() implementation, similar to strtoul() but returning
    an range-checked unsigned int instead */
-unsigned int strtoui(const char *nptr,char **endptr,int base)
+uint32_t strtoid(const char *nptr,char **endptr,int base)
 {
-  unsigned long val;
-  val=strtoul(nptr,endptr,base);
-  if (val>UINT_MAX)
+  long long val;
+
+  val=strtoll(nptr,endptr,base);
+  if (val>UINT32_MAX)
   {
     errno=ERANGE;
-    return UINT_MAX;
+    return UINT32_MAX;
   }
-  /* If errno was set by strtoull, we'll pass it back as-is */
-  return (unsigned int)val;
+  else if (val<0)
+  {
+    errno=EINVAL;
+    return UINT32_MAX;
+  }
+
+  /* If errno was set, we'll pass it back as-is */
+  return (uint32_t) val;
 }
-#endif /* WANT_STRTOUI */
diff -up nss-pam-ldapd-0.7.17/nslcd/common.h.overflow nss-pam-ldapd-0.7.17/nslcd/common.h
--- nss-pam-ldapd-0.7.17/nslcd/common.h.overflow	2012-09-09 19:51:49.826786849 +0200
+++ nss-pam-ldapd-0.7.17/nslcd/common.h	2012-09-09 19:52:53.669988699 +0200
@@ -98,31 +98,9 @@ MYLDAP_ENTRY *uid2entry(MYLDAP_SESSION *
 /* transforms the uid into a DN by doing an LDAP lookup */
 MUST_USE char *uid2dn(MYLDAP_SESSION *session,const char *uid,char *buf,size_t buflen);
 
-/* provide strtouid() function alias */
-#if SIZEOF_UID_T == SIZEOF_UNSIGNED_LONG_INT
-#define strtouid (uid_t)strtoul
-#elif SIZEOF_UID_T == SIZEOF_UNSIGNED_LONG_LONG_INT
-#define strtouid (uid_t)strtoull
-#elif SIZEOF_UID_T == SIZEOF_UNSIGNED_INT
-#define WANT_STRTOUI 1
-#define strtouid (uid_t)strtoui
-#else
-#error unable to find implementation for strtouid()
-#endif
-
-/* provide strtouid() function alias */
-#if SIZEOF_GID_T == SIZEOF_UNSIGNED_LONG_INT
-#define strtogid (gid_t)strtoul
-#elif SIZEOF_GID_T == SIZEOF_UNSIGNED_LONG_LONG_INT
-#define strtogid (gid_t)strtoull
-#elif SIZEOF_GID_T == SIZEOF_UNSIGNED_INT
-#ifndef WANT_STRTOUI
-#define WANT_STRTOUI 1
-#endif
-#define strtogid (uid_t)strtoui
-#else
-#error unable to find implementation for strtogid()
-#endif
+uint32_t strtoid(const char *nptr,char **endptr,int base);
+#define strtouid (uid_t)strtoid
+#define strtogid (uid_t)strtoid
 
 #ifdef WANT_STRTOUI
 /* provide a strtoui() if it is needed */