diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.in | 4 | ||||
-rw-r--r-- | src/assuan-support.c | 14 | ||||
-rw-r--r-- | src/b64dec.c | 2 | ||||
-rw-r--r-- | src/conversion.c | 56 | ||||
-rw-r--r-- | src/data-identify.c | 2 | ||||
-rw-r--r-- | src/engine-gpg.c | 4 | ||||
-rw-r--r-- | src/gpgme.def | 2 | ||||
-rw-r--r-- | src/gpgme.h.in | 6 | ||||
-rw-r--r-- | src/libgpgme.vers | 2 | ||||
-rw-r--r-- | src/mbox-util.c | 20 | ||||
-rw-r--r-- | src/mbox-util.h | 2 | ||||
-rw-r--r-- | src/util.h | 10 | ||||
-rw-r--r-- | src/w32-util.c | 39 |
13 files changed, 130 insertions, 33 deletions
diff --git a/src/Makefile.in b/src/Makefile.in index 75d7659..d70de3b 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -107,8 +107,8 @@ subdir = src DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/build-aux/mkinstalldirs \ $(srcdir)/versioninfo.rc.in $(srcdir)/gpgme.h.in \ - $(srcdir)/gpgme-config.in setenv.c stpcpy.c vasprintf.c \ - ttyname_r.c funopen.c $(top_srcdir)/build-aux/depcomp + $(srcdir)/gpgme-config.in vasprintf.c funopen.c stpcpy.c \ + setenv.c ttyname_r.c $(top_srcdir)/build-aux/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_cxx_compile_stdcxx.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ diff --git a/src/assuan-support.c b/src/assuan-support.c index 2cfdc35..7fbd48a 100644 --- a/src/assuan-support.c +++ b/src/assuan-support.c @@ -97,6 +97,9 @@ my_recvmsg (assuan_context_t ctx, assuan_fd_t fd, assuan_msghdr_t msg, { (void)ctx; #ifdef HAVE_W32_SYSTEM + (void)fd; + (void)msg; + (void)flags; gpg_err_set_errno (ENOSYS); return -1; #else @@ -112,6 +115,9 @@ my_sendmsg (assuan_context_t ctx, assuan_fd_t fd, const assuan_msghdr_t msg, { (void)ctx; #ifdef HAVE_W32_SYSTEM + (void)fd; + (void)msg; + (void)flags; gpg_err_set_errno (ENOSYS); return -1; #else @@ -210,6 +216,9 @@ my_waitpid (assuan_context_t ctx, pid_t pid, { (void)ctx; #ifdef HAVE_W32_SYSTEM + (void)nowait; + (void)status; + (void)options; CloseHandle ((HANDLE) pid); #else /* We can't just release the PID, a waitpid is mandatory. But @@ -229,6 +238,11 @@ my_socketpair (assuan_context_t ctx, int namespace, int style, int protocol, assuan_fd_t filedes[2]) { #ifdef HAVE_W32_SYSTEM + (void)ctx; + (void)namespace; + (void)style; + (void)protocol; + (void)filedes; gpg_err_set_errno (ENOSYS); return -1; #else diff --git a/src/b64dec.c b/src/b64dec.c index 7965a30..9a7efca 100644 --- a/src/b64dec.c +++ b/src/b64dec.c @@ -12,7 +12,7 @@ * This file is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, see <http://www.gnu.org/licenses/>. diff --git a/src/conversion.c b/src/conversion.c index 3df8fe5..6dfabe7 100644 --- a/src/conversion.c +++ b/src/conversion.c @@ -31,6 +31,7 @@ #endif #include <time.h> #include <errno.h> +#include <stdarg.h> #include "gpgme.h" #include "util.h" @@ -42,6 +43,61 @@ +static char * +do_strconcat (const char *s1, va_list arg_ptr) +{ + const char *argv[16]; + size_t argc; + size_t needed; + char *buffer, *p; + + argc = 0; + argv[argc++] = s1; + needed = strlen (s1); + while (((argv[argc] = va_arg (arg_ptr, const char *)))) + { + needed += strlen (argv[argc]); + if (argc >= DIM (argv)-1) + { + gpg_err_set_errno (EINVAL); + return NULL; + } + argc++; + } + needed++; + buffer = malloc (needed); + if (buffer) + { + for (p = buffer, argc=0; argv[argc]; argc++) + p = stpcpy (p, argv[argc]); + } + return buffer; +} + + +/* Concatenate the string S1 with all the following strings up to a + * NULL. Returns a malloced buffer with the new string or NULL on a + malloc error or if too many arguments are given. */ +char * +_gpgme_strconcat (const char *s1, ...) +{ + va_list arg_ptr; + char *result; + + if (!s1) + result = strdup (""); + else + { + va_start (arg_ptr, s1); + result = do_strconcat (s1, arg_ptr); + va_end (arg_ptr); + } + return result; +} + + + + /* Convert two hexadecimal digits from STR to the value they represent. Returns -1 if one of the characters is not a hexadecimal digit. */ diff --git a/src/data-identify.c b/src/data-identify.c index a5da7f5..615a4f3 100644 --- a/src/data-identify.c +++ b/src/data-identify.c @@ -278,7 +278,7 @@ pgp_binary_detection (const void *image_arg, size_t imagelen) /* This is probably an armored "PGP MESSAGE" which can encode * different PGP data types. STRING is modified after a call to this - * fucntion. */ + * function. */ static gpgme_data_type_t inspect_pgp_message (char *string) { diff --git a/src/engine-gpg.c b/src/engine-gpg.c index 8bb348f..4415c94 100644 --- a/src/engine-gpg.c +++ b/src/engine-gpg.c @@ -544,6 +544,8 @@ gpg_new (void **engine, const char *file_name, const char *home_dir, rc = add_arg (gpg, "utf8"); if (!rc) rc = add_arg (gpg, "--enable-progress-filter"); + if (!rc && have_gpg_version (gpg, "2.1.11")) + rc = add_arg (gpg, "--exit-on-status-write-error"); if (rc) goto leave; @@ -2541,7 +2543,7 @@ gpg_keylist_build_options (engine_gpg_t gpg, int secret_only, err = add_arg (gpg, "--with-colons"); /* Since gpg 2.1.15 fingerprints are always printed, thus there is - * no more need to explictly request them. */ + * no more need to explicitly request them. */ if (!have_gpg_version (gpg, "2.1.15")) { if (!err) diff --git a/src/gpgme.def b/src/gpgme.def index 9815a83..c94c960 100644 --- a/src/gpgme.def +++ b/src/gpgme.def @@ -244,5 +244,7 @@ EXPORTS gpgme_op_interact_start @184 gpgme_op_interact @185 + gpgme_addrspec_from_uid @186 + ; END diff --git a/src/gpgme.h.in b/src/gpgme.h.in index 20654db..5c914ae 100644 --- a/src/gpgme.h.in +++ b/src/gpgme.h.in @@ -846,7 +846,7 @@ struct _gpgme_user_id /* The mail address (addr-spec from RFC5322) of the UID string. * This is general the same as the EMAIL part of this struct but - * might be slightly different. IF no mail address is available + * might be slightly different. If no mail address is available * NULL is stored. */ char *address; @@ -2471,6 +2471,10 @@ const char *gpgme_pubkey_algo_name (gpgme_pubkey_algo_t algo); algorithm ALGO, or NULL if that name is not known. */ const char *gpgme_hash_algo_name (gpgme_hash_algo_t algo); +/* Return the addr-spec from a user id. Caller must free the result + * with gpgme_free. */ +char *gpgme_addrspec_from_uid (const char *uid); + /* diff --git a/src/libgpgme.vers b/src/libgpgme.vers index aec9090..d3962db 100644 --- a/src/libgpgme.vers +++ b/src/libgpgme.vers @@ -117,6 +117,8 @@ GPGME_1.1 { gpgme_op_tofu_policy; gpgme_op_interact_start; gpgme_op_interact; + + gpgme_addrspec_from_uid; }; diff --git a/src/mbox-util.c b/src/mbox-util.c index 83c8b5e..81e929b 100644 --- a/src/mbox-util.c +++ b/src/mbox-util.c @@ -12,7 +12,7 @@ * This file is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, see <http://www.gnu.org/licenses/>. @@ -255,3 +255,21 @@ _gpgme_mailbox_from_userid (const char *userid) /* return 1; */ /* } */ + + +/* + * Exported public API + */ + + +/* Return the mail address ("addr-spec" as per RFC-5322) from a string + * which is assumed to be an user id ("address" in RFC-5322). All + * plain ASCII characters (those with bit 7 cleared) in the result + * are converted to lowercase. Caller must free the result using + * gpgme_free. Returns NULL if no valid address was found (in which + * case ERRNO is set to EINVAL) or for other errors. */ +char * +gpgme_addrspec_from_uid (const char *uid) +{ + return _gpgme_mailbox_from_userid (uid); +} diff --git a/src/mbox-util.h b/src/mbox-util.h index 3195a4d..c5747b6 100644 --- a/src/mbox-util.h +++ b/src/mbox-util.h @@ -11,7 +11,7 @@ * This file is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, see <http://www.gnu.org/licenses/>. @@ -49,6 +49,10 @@ # define GPG_ERR_FALSE 256 #endif +#ifndef GPGRT_ATTR_SENTINEL +# define GPGRT_ATTR_SENTINEL(a) /* */ +#endif + /*-- {posix,w32}-util.c --*/ @@ -102,6 +106,12 @@ int _gpgme_ttyname_r (int fd, char *buf, size_t buflen); /*-- conversion.c --*/ + +/* Concatenate the string S1 with all the following strings up to a + NULL. Returns a malloced buffer with the new string or NULL on a + malloc error or if too many arguments are given. */ +char *_gpgme_strconcat (const char *s1, ...) GPGRT_ATTR_SENTINEL(0); + /* Convert two hexadecimal digits from STR to the value they represent. Returns -1 if one of the characters is not a hexadecimal digit. */ diff --git a/src/w32-util.c b/src/w32-util.c index 0086fe3..21de6dc 100644 --- a/src/w32-util.c +++ b/src/w32-util.c @@ -98,6 +98,8 @@ static GPG_ERR_INLINE void * dlopen (const char * name, int flag) { void * hd = LoadLibrary (name); + + (void)flag; return hd; } @@ -388,11 +390,10 @@ find_program_in_dir (const char *dir, const char *name) { char *result; - result = malloc (strlen (dir) + 1 + strlen (name) + 1); + result = _gpgme_strconcat (dir, "\\", name, NULL); if (!result) return NULL; - strcpy (stpcpy (stpcpy (result, dir), "\\"), name); if (access (result, F_OK)) { free (result); @@ -417,15 +418,11 @@ find_program_at_standard_place (const char *name) if (SHGetSpecialFolderPathA (NULL, path, CSIDL_PROGRAM_FILES, 0) || SHGetSpecialFolderPathA (NULL, path, CSIDL_PROGRAM_FILESX86, 0)) { - result = malloc (strlen (path) + 1 + strlen (name) + 1); - if (result) + result = _gpgme_strconcat (path, "\\", name, NULL); + if (result && access (result, F_OK)) { - strcpy (stpcpy (stpcpy (result, path), "\\"), name); - if (access (result, F_OK)) - { - free (result); - result = NULL; - } + free (result); + result = NULL; } } return result; @@ -439,12 +436,9 @@ _gpgme_set_default_gpg_name (const char *name) { if (!default_gpg_name) { - default_gpg_name = malloc (strlen (name) + 5); + default_gpg_name = _gpgme_strconcat (name, ".exe", NULL); if (default_gpg_name) - { - strcpy (stpcpy (default_gpg_name, name), ".exe"); - replace_slashes (default_gpg_name); - } + replace_slashes (default_gpg_name); } return !default_gpg_name; } @@ -456,12 +450,9 @@ _gpgme_set_default_gpgconf_name (const char *name) { if (!default_gpgconf_name) { - default_gpgconf_name = malloc (strlen (name) + 5); + default_gpgconf_name = _gpgme_strconcat (name, ".exe", NULL); if (default_gpgconf_name) - { - strcpy (stpcpy (default_gpgconf_name, name), ".exe"); - replace_slashes (default_gpgconf_name); - } + replace_slashes (default_gpgconf_name); } return !default_gpgconf_name; } @@ -474,10 +465,9 @@ _gpgme_set_override_inst_dir (const char *dir) { if (!override_inst_dir) { - override_inst_dir = malloc (strlen (dir) + 1); + override_inst_dir = strdup (dir); if (override_inst_dir) { - strcpy (override_inst_dir, dir); replace_slashes (override_inst_dir); /* Remove a trailing slash. */ if (*override_inst_dir @@ -762,12 +752,11 @@ _gpgme_mkstemp (int *fd, char **name) } } - tmpname = malloc (strlen (tmp) + 13 + 1); + tmpname = _gpgme_strconcat (tmp, "\\gpgme-XXXXXX", NULL); if (!tmpname) return -1; - strcpy (stpcpy (tmpname, tmp), "\\gpgme-XXXXXX"); *fd = my_mkstemp (tmpname); - if (fd < 0) + if (*fd < 0) { free (tmpname); return -1; |