lists.arthurdejong.org
RSS feed

Re: [PATCH] Do not truncate large UID/GID values on 32bit architectures

[Date Prev][Date Next] [Thread Prev][Thread Next]

Re: [PATCH] Do not truncate large UID/GID values on 32bit architectures



On Fri, 2011-08-26 at 20:59 +0200, Jakub Hrozek wrote:
> nslcd used strtol() for converting UID/GID attributes into their numeric
> form. The conversion does not work correctly on 32bit architectures because
> large UID/GIDs values do not fit into LONG_MAX there.
> 
> The attached patch uses a new function strtouint32() to convert strings
> to IDs. This way, even large ID values can be converted safely and also
> IDs that overflow the UINT32_MAX value are detected.
> 
> Please see https://bugzilla.redhat.com/show_bug.cgi?id=720230#c3 for a
> reproducer, for example.

Thanks for your patch, very much appreciated. I've just two issues with
that patch:
- it hard-codes it to uint32, instead it would be nicer to have a
  strtouid() and strtogid() that would do the right thing on all
  platforms (e.g. a platform could have 16, 32, or in theory 64-bit
  uids)
- I think setting errno to 0 should be done before the call to
  strtouint32() to follow what strtoll() does (I like the idea of
  logging overflows)

Again, thanks for your patch. It's very much appreciated, I've made the
second change already in r1523:
  http://arthurdejong.org/viewvc/nss-pam-ldapd?view=rev&revision=1523

I think the first issue could be addressed by picking strtoul() or
strtoull() depending on the size of long int, long long int and uid_t.

-- 
-- arthur - arthur@arthurdejong.org - http://arthurdejong.org --
-- 
To unsubscribe send an email to
nss-pam-ldapd-users-unsubscribe@lists.arthurdejong.org or see
http://lists.arthurdejong.org/nss-pam-ldapd-users