common: Fix commit f99830b.

* common/userids.c (classify_user_id): Avoid underflow.  Use spacep to
also trim tabs.
--

This is actually not fully consistent because the now used
trim_trailing_spaces uses the locale dependent isspace and not spacep.
Given that the use of isspace is anyway problematic we should check
whether we can chnage trim_trailing_spaces.

Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
Werner Koch 2015-11-06 13:20:01 +01:00
parent 28e198201e
commit 20125333e7
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B
1 changed files with 8 additions and 4 deletions

View File

@ -89,11 +89,15 @@ classify_user_id (const char *name, KEYDB_SEARCH_DESC *desc, int openpgp_hack)
/* Skip leading and trailing spaces. */
for(s = name; *s && spacep (s); s++ )
;
if (s[strlen(s) - 1] == ' ')
if (*s && spacep (s + strlen(s) - 1))
{
s2 = xstrdup (s);
while (s2[strlen(s2) - 1] == ' ')
s2[strlen(s2) - 1] = 0;
s2 = xtrystrdup (s);
if (!s2)
{
rc = gpg_error_from_syserror ();
goto out;
}
trim_trailing_spaces (s2);
s = s2;
}