diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2018-08-15 22:22:31 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2018-08-15 22:22:31 +0300 |
commit | 7a40b7873bd666809183cdd952d6e2a8f1870981 (patch) | |
tree | 0ae71532dc78f597b717152b564d6681d1ad832a /lib/base64.c | |
parent | 988b8e27f5df26d7e9f6fd7984677873ca1c40cb (diff) | |
download | pam-modules-7a40b7873bd666809183cdd952d6e2a8f1870981.tar.gz pam-modules-7a40b7873bd666809183cdd952d6e2a8f1870981.tar.bz2 |
Major cleanup
* lib/graypam.h (gray_pam_init)
(gray_raise,gray_malloc,gray_zalloc,gray_calloc)
(gray_realloc,gray_strdup): Remove.
(gray_slist_err,gray_slist_clrerr): New functions.
(gray_slist_append,gray_slist_append_char): Return ssize_t.
(gray_slist_coalesce): Likewise.
(gray_slist_grow_backslash_num)
(gray_slist_grow_backslash): Return int.
(errno_to_pam): New function.
(gray_set_transform_expr): Return int.
* lib/mem.c (gray_raise,gray_malloc,gray_zalloc,gray_calloc)
(gray_realloc,gray_strdup): Remove.
(gray_2nrealloc): Rewrite.
* lib/base64.c: Check return from gray_slist_append_char
* lib/env.c: Check return values from gray_slist functions
* lib/ldappass.c: Likewise.
* lib/slist.c (gray_slist_bucket) <ec>: New member.
(gray_slist_err,gray_slist_clrerr): New functions.
(gray_slist_append,gray_slist_append_char): Return ssize_t.
(gray_slist_coalesce): Likewise.
(gray_slist_grow_backslash_num)
(gray_slist_grow_backslash): Return int.
* lib/transform.c: Use standard memory allocation functions.
* pam_ldaphome/pam_ldaphome.c: Likewise.
* pam_innetgr/pam_innetgr.c: Likewise.
* pam_log/pam_log.c: Likewise.
* pam_regex/pam_regex.c: Likewise.
* pam_sql/pam_mysql.c: Likewise.
* pam_sql/pam_pgsql.c: Likewise.
Diffstat (limited to 'lib/base64.c')
-rw-r--r-- | lib/base64.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/lib/base64.c b/lib/base64.c index 85b974a..9d0191e 100644 --- a/lib/base64.c +++ b/lib/base64.c @@ -54,15 +54,21 @@ gray_base64_decode(gray_slist_t slist, const char *iptr, size_t isize) /* I have a entire block of data 32 bits get the output data. */ if (i == 4) { - gray_slist_append_char(slist, - (data[0] << 2) | ((data[1] & 0x30) >> 4)); - gray_slist_append_char(slist, - ((data[1] & 0xf) << 4) | ((data[2] & 0x3c) >> 2)); - gray_slist_append_char(slist, - ((data[2] & 0x3) << 6) | data[3]); + if (gray_slist_append_char(slist, + (data[0] << 2) | ((data[1] & 0x30) >> 4)) != 1) + return -1; + if (gray_slist_append_char(slist, + ((data[1] & 0xf) << 4) | ((data[2] & 0x3c) >> 2)) + != 1) + return -1; + if (gray_slist_append_char(slist, + ((data[2] & 0x3) << 6) | data[3]) != 1) + return -1; nbytes += 3 - pad; - } else + } else { + errno = EILSEQ; return -1; + } i = 0; } return nbytes; |