Control: tags -1 moreinfo On Sat, Sep 23, 2017 at 23:48:54 +0200, Jose Gutierrez de la Concha wrote:
> diff -Nru zeroc-ice-3.6.3/cpp/src/Ice/Instance.cpp > zeroc-ice-3.6.4/cpp/src/Ice/Instance.cpp > --- zeroc-ice-3.6.3/cpp/src/Ice/Instance.cpp 2016-10-05 14:59:08.000000000 > +0000 > +++ zeroc-ice-3.6.4/cpp/src/Ice/Instance.cpp 2017-09-07 18:12:55.000000000 > +0000 > @@ -1,6 +1,6 @@ > // ********************************************************************** > // > -// Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved. > +// Copyright (c) 2003-2017 ZeroC, Inc. All rights reserved. > // > // This copy of Ice is licensed to you under the terms described in the > // ICE_LICENSE file included in this distribution. > @@ -184,7 +184,6 @@ > const InstancePtr _instance; > }; > > - > // > // Timer specialization which supports the thread observer > // > @@ -1064,6 +1063,7 @@ > _initData(initData), > _messageSizeMax(0), > _batchAutoFlushSize(0), > + _classGraphDepthMax(0), > _collectObjects(false), > _implicitContext(0), > _stringConverter(IceUtil::getProcessStringConverter()), > @@ -1132,21 +1132,25 @@ > string newUser = > _initData.properties->getProperty("Ice.ChangeUser"); > if(!newUser.empty()) > { > - errno = 0; > - struct passwd* pw = getpwnam(newUser.c_str()); > - if(!pw) > + struct passwd pwbuf; > + vector<char> buffer(4096); // 4KB initial buffer > + struct passwd *pw; > + int err = getpwnam_r(newUser.c_str(), &pwbuf, > &buffer[0], buffer.size(), &pw); > + while(err == ERANGE && buffer.size() < 1024 * 1024) // > Limit buffer to 1MB > { > - if(errno) > - { > - SyscallException ex(__FILE__, __LINE__); > - ex.error = getSystemErrno(); > - throw ex; > - } > - else > - { > - InitializationException ex(__FILE__, __LINE__, > "Unknown user account `" + newUser + "'"); > - throw ex; > - } > + buffer.resize(buffer.size() * 2); > + } > + if(err != 0) > + { > + Ice::SyscallException ex(__FILE__, __LINE__); > + ex.error = err; > + throw ex; > + } > + else if(pw == 0) > + { > + InitializationException ex(__FILE__, __LINE__); > + ex.reason ="unknown user account `" + newUser + "'"; > + throw ex; > } > > if(setgid(pw->pw_gid) == -1) That new loop looks broken. It seems the intention was to extend the buffer until getpwnam_r was happy, but getpwnam_r is only ever called with the initial 4k buffer? Cheers, Julien