On Mon, Dec 10, 2018 at 06:49:43PM +0100, Tomas Mraz wrote:
On Mon, 2018-12-10 at 20:23 +0300, Dmitry V. Levin wrote:
> On Mon, Dec 10, 2018 at 05:01:47PM +0100, Tomas Mraz wrote:
> > The attached patch moves the implementation of search_key function
> > that
> > was duplicated in multiple PAM modules into a new
> > pam_modutil_search_key function.
> >
> > I plan to add one more place where it will be used - pam_lastlog.
> >
> > OK to commit?
>
> [...]
> > + tmp = strsep (&cp, " \t=");
> > + if (cp != NULL)
> > + while (isspace((int)*cp) || *cp == '=')
> > + ++cp;
> > +
> > + if (strcasecmp(tmp, key) == 0) {
> > + retval = strdup(cp);
> > + break;
> > + }
>
> This piece of code looks problematic:
> if the string contains a key without a value, you'll get cp == NULL
> and will end up with strdup(NULL).
OK, let's return empty string in that case.
Thanks.
+ tmp = strsep (&cp, " \t=");
+ if (cp != NULL)
+ while (isspace((int)*cp) || *cp == '=')
+ ++cp;
+ else
+ cp = "";
I don't quite like the way how it handles strings like
FAIL_DELAY = = = = = 0
but this could be addressed later.
--
ldv