FOSUserBundle icon indicating copy to clipboard operation
FOSUserBundle copied to clipboard

Password set as 2147483647

Open nirodg opened this issue 12 years ago • 5 comments

Through Android i create a new user and 1 of 5 times the password becomes automatically on 2147483647. I used Google to found a possible answer to that and some people say it's an overflow caused by Apache

Here's a piese os the code:

        public function userRegisterAction(Request $request) {
                ......
                $getPass = $request->query->get('password');
                $userManager = $this->container->get('fos_user.user_manager');

                $newUser->setUsername($getUser);
                $newUser->setPlainPassword($getPass);
                ......
                $userManager->updateUser($newUser);
        }

Any help is welcome :)

nirodg avatar Jul 18 '14 08:07 nirodg

what is the content of $getPass here ? Is it 2147483647 or your real password ?

stof avatar Jul 18 '14 08:07 stof

It seems its a number that gets converted to an integer, and overflows.

sstok avatar Jul 18 '14 08:07 sstok

well, if the password you pass to FOSUserBundle is already this number, there is no bug in FOSUserBundle, but in the code you are running before.

stof avatar Jul 18 '14 08:07 stof

For example, as a password i set "example12345" and 1 of 5 times automatically the password is 2147483647. Even i looked the User.php inside of FOS/UserBundule/Model/User and the Password variable is a protected string.

nirodg avatar Jul 18 '14 08:07 nirodg

I don't know if i solved the problem but I created around 10 users with the App and works perfect. I used (string) before the $request

$getPass = (string) $request->query->get('password');

I found a possible explication of the problem:

When posting a string of numbers with an integer representation greater than 2147483647, PHP casts the string to an integer type and sets the value to 2147483647.

Symfony should check for posted values and overflows - casting integers larger than the maximum allowed to strings. 

Anyway, thanks for the help :)

nirodg avatar Jul 18 '14 09:07 nirodg