diff options
author | Werner Koch <wk@gnupg.org> | 2015-11-06 13:20:01 +0100 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2015-11-06 13:25:00 +0100 |
commit | 20125333e7b822e8c70ac8cef986649f0654eb56 (patch) | |
tree | cb74a884e3ef8c9f93818f1da2353d4bdeb4f029 /common/userids.c | |
parent | gpg: Fix formatting string. (diff) | |
download | gnupg2-20125333e7b822e8c70ac8cef986649f0654eb56.tar.xz gnupg2-20125333e7b822e8c70ac8cef986649f0654eb56.zip |
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>
Diffstat (limited to 'common/userids.c')
-rw-r--r-- | common/userids.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/common/userids.c b/common/userids.c index 25d67410e..f9a003607 100644 --- a/common/userids.c +++ b/common/userids.c @@ -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; } |