[haiku-commits] Re: haiku: hrev50628 - src/system/libroot/posix/unistd

  • From: Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sat, 29 Oct 2016 22:57:17 +0200

Am 29/10/2016 um 22:40 schrieb jerome.duval@xxxxxxxxx:

-       if (pw && (nameSize > 32/*PW_MAX_NAME*/)) {
+       if (pw && (nameSize >= LOGIN_NAME_MAX)) {
                memset(name, 0, nameSize);
-               strlcpy(name, pw->pw_name, 32/*PW_MAX_NAME*/);
+               strlcpy(name, pw->pw_name, LOGIN_NAME_MAX);

Shouldn't that be something like:

        int needed = strlcpy(name, pw->pw_name, nameSize);
        if (needed > nameSize)
                return ENOMEM;
        return B_OK;

?
Why only accept "name" if it's equal or larger than the maximum, and then only write the maximum to it?

Bye,
   Axel.

Other related posts: