diff --git a/ChangeLog b/ChangeLog index a4bac215..6ede27ee 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2009-06-22 Marcus Brinkmann + + * configure.ac: Add AC_TYPE_UINTPTR_T. + + * assuan/assuan.h [_ASSUAN_IN_GPGME_BUILD_ASSUAN]: Declare + _gpgme_io_connect. + 2009-06-18 Marcus Brinkmann Released GPGME 1.2.0. diff --git a/assuan/assuan.h b/assuan/assuan.h index 971ff4d9..68b30f5a 100644 --- a/assuan/assuan.h +++ b/assuan/assuan.h @@ -75,6 +75,7 @@ int _gpgme_io_close (int fd); int _gpgme_io_read (int fd, void *buffer, size_t count); int _gpgme_io_write (int fd, const void *buffer, size_t count); +int _gpgme_io_connect (int fd, struct sockaddr *addr, int addrlen); int _gpgme_io_sendmsg (int sock, const struct msghdr *msg, int flags); int _gpgme_io_recvmsg (int sock, struct msghdr *msg, int flags); int _gpgme_io_socket (int domain, int type, int proto); diff --git a/configure.ac b/configure.ac index 75d0c8f0..9459c37e 100644 --- a/configure.ac +++ b/configure.ac @@ -197,6 +197,7 @@ AC_C_INLINE AC_CHECK_SIZEOF(unsigned int) AC_SYS_LARGEFILE AC_TYPE_OFF_T +AC_TYPE_UINTPTR_T # A simple compile time check in gpgme.h for GNU/Linux systems that # prevents a file offset bits mismatch between gpgme and the application. diff --git a/src/ChangeLog b/src/ChangeLog index ef2310fe..56a215d9 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,20 @@ +2009-06-22 Marcus Brinkmann + + * debug.h: Everywhere, use %p instead of 0x%x to print pointer. + [HAVE_STDINT_H]: Include . + (_TRACE, TRACE, TRACE0, TRACE1, TRACE2, TRACE3, TRACE6): Cast tag + to (uintptr_t) before casting it to (void*) to silence GCC + warning. + + * gpgme.h.in (_GPGME_DEPRECATED_OUTSIDE_GPGME): New macro. + * sign.c (_GPGME_IN_GPGME): Define it. + * keylist.c (_GPGME_IN_GPGME): Define it. + + * debug.c (_gpgme_debug_begin, _gpgme_debug_add): Handle error in + vasprintf and asprintf. + + * priv-io.h: Include . Declare _gpgme_io_connect. + 2009-06-18 Marcus Brinkmann * gpgme.h.in (GPGME_CONF_PATHNAME): Revert last change, it's diff --git a/src/debug.c b/src/debug.c index d529653a..979c6256 100644 --- a/src/debug.c +++ b/src/debug.c @@ -1,6 +1,6 @@ /* debug.c - helpful output in desperate situations Copyright (C) 2000 Werner Koch (dd9jn) - Copyright (C) 2001, 2002, 2003, 2004, 2005, 2007 g10 Code GmbH + Copyright (C) 2001, 2002, 2003, 2004, 2005, 2007, 2009 g10 Code GmbH This file is part of GPGME. @@ -197,6 +197,7 @@ void _gpgme_debug_begin (void **line, int level, const char *format, ...) { va_list arg_ptr; + int res; debug_init (); if (debug_level < level) @@ -207,8 +208,10 @@ _gpgme_debug_begin (void **line, int level, const char *format, ...) } va_start (arg_ptr, format); - vasprintf ((char **) line, format, arg_ptr); + res = vasprintf ((char **) line, format, arg_ptr); va_end (arg_ptr); + if (res < 0) + *line = NULL; } @@ -219,17 +222,26 @@ _gpgme_debug_add (void **line, const char *format, ...) va_list arg_ptr; char *toadd; char *result; + int res; if (!*line) return; va_start (arg_ptr, format); - vasprintf (&toadd, format, arg_ptr); + res = vasprintf (&toadd, format, arg_ptr); va_end (arg_ptr); - asprintf (&result, "%s%s", *(char **) line, toadd); - free (*line); + if (res < 0) + { + free (*line); + *line = NULL; + } + res = asprintf (&result, "%s%s", *(char **) line, toadd); free (toadd); - *line = result; + free (*line); + if (res < 0) + *line = NULL; + else + *line = result; } diff --git a/src/debug.h b/src/debug.h index 1083c668..766c03fe 100644 --- a/src/debug.h +++ b/src/debug.h @@ -22,6 +22,9 @@ #define DEBUG_H #include +#ifdef HAVE_STDINT_H +#include +#endif /* Indirect stringification, requires __STDC__ to work. */ #define STRINGIFY(v) #v @@ -81,133 +84,134 @@ void _gpgme_debug_buffer (int lvl, const char *const fmt, int _gpgme_trace_level = lvl; \ const char *const _gpgme_trace_func = name; \ const char *const _gpgme_trace_tagname = STRINGIFY (tag); \ - void *_gpgme_trace_tag = (void *) tag + void *_gpgme_trace_tag = (void *) (uintptr_t) tag #define TRACE_BEG(lvl, name, tag) \ _TRACE (lvl, name, tag); \ - _gpgme_debug (_gpgme_trace_level, "%s (%s=0x%x): enter\n", \ + _gpgme_debug (_gpgme_trace_level, "%s (%s=%p): enter\n", \ _gpgme_trace_func, _gpgme_trace_tagname, \ _gpgme_trace_tag), 0 #define TRACE_BEG0(lvl, name, tag, fmt) \ _TRACE (lvl, name, tag); \ - _gpgme_debug (_gpgme_trace_level, "%s (%s=0x%x): enter: " fmt "\n", \ + _gpgme_debug (_gpgme_trace_level, "%s (%s=%p): enter: " fmt "\n", \ _gpgme_trace_func, _gpgme_trace_tagname, \ _gpgme_trace_tag), 0 #define TRACE_BEG1(lvl, name, tag, fmt, arg1) \ _TRACE (lvl, name, tag); \ - _gpgme_debug (_gpgme_trace_level, "%s (%s=0x%x): enter: " fmt "\n", \ + _gpgme_debug (_gpgme_trace_level, "%s (%s=%p): enter: " fmt "\n", \ _gpgme_trace_func, _gpgme_trace_tagname, \ _gpgme_trace_tag, arg1), 0 #define TRACE_BEG2(lvl, name, tag, fmt, arg1, arg2) \ _TRACE (lvl, name, tag); \ - _gpgme_debug (_gpgme_trace_level, "%s (%s=0x%x): enter: " fmt "\n", \ + _gpgme_debug (_gpgme_trace_level, "%s (%s=%p): enter: " fmt "\n", \ _gpgme_trace_func, _gpgme_trace_tagname, \ _gpgme_trace_tag, arg1, arg2), 0 #define TRACE_BEG3(lvl, name, tag, fmt, arg1, arg2, arg3) \ _TRACE (lvl, name, tag); \ - _gpgme_debug (_gpgme_trace_level, "%s (%s=0x%x): enter: " fmt "\n", \ + _gpgme_debug (_gpgme_trace_level, "%s (%s=%p): enter: " fmt "\n", \ _gpgme_trace_func, _gpgme_trace_tagname, \ _gpgme_trace_tag, arg1, arg2, arg3), 0 #define TRACE_BEG4(lvl, name, tag, fmt, arg1, arg2, arg3, arg4) \ _TRACE (lvl, name, tag); \ - _gpgme_debug (_gpgme_trace_level, "%s (%s=0x%x): enter: " fmt "\n", \ + _gpgme_debug (_gpgme_trace_level, "%s (%s=%p): enter: " fmt "\n", \ _gpgme_trace_func, _gpgme_trace_tagname, \ _gpgme_trace_tag, arg1, arg2, arg3, arg4), 0 #define TRACE(lvl, name, tag) \ - _gpgme_debug (lvl, "%s (%s=0x%x): call\n", \ - name, STRINGIFY (tag), (void *) tag), 0 + _gpgme_debug (lvl, "%s (%s=%p): call\n", \ + name, STRINGIFY (tag), (void *) (uintptr_t) tag), 0 #define TRACE0(lvl, name, tag, fmt) \ - _gpgme_debug (lvl, "%s (%s=0x%x): call: " fmt "\n", \ - name, STRINGIFY (tag), (void *) tag), 0 + _gpgme_debug (lvl, "%s (%s=%p): call: " fmt "\n", \ + name, STRINGIFY (tag), (void *) (uintptr_t) tag), 0 #define TRACE1(lvl, name, tag, fmt, arg1) \ - _gpgme_debug (lvl, "%s (%s=0x%x): call: " fmt "\n", \ - name, STRINGIFY (tag), (void *) tag, arg1), 0 + _gpgme_debug (lvl, "%s (%s=%p): call: " fmt "\n", \ + name, STRINGIFY (tag), (void *) (uintptr_t) tag, arg1), 0 #define TRACE2(lvl, name, tag, fmt, arg1, arg2) \ - _gpgme_debug (lvl, "%s (%s=0x%x): call: " fmt "\n", \ - name, STRINGIFY (tag), (void *) tag, arg1, arg2), 0 + _gpgme_debug (lvl, "%s (%s=%p): call: " fmt "\n", \ + name, STRINGIFY (tag), (void *) (uintptr_t) tag, arg1, \ + arg2), 0 #define TRACE3(lvl, name, tag, fmt, arg1, arg2, arg3) \ - _gpgme_debug (lvl, "%s (%s=0x%x): call: " fmt "\n", \ - name, STRINGIFY (tag), (void *) tag, arg1, arg2, \ - arg3), 0 + _gpgme_debug (lvl, "%s (%s=%p): call: " fmt "\n", \ + name, STRINGIFY (tag), (void *) (uintptr_t) tag, arg1, \ + arg2, arg3), 0 #define TRACE6(lvl, name, tag, fmt, arg1, arg2, arg3, arg4, arg5, arg6) \ - _gpgme_debug (lvl, "%s (%s=0x%x): call: " fmt "\n", \ - name, STRINGIFY (tag), (void *) tag, arg1, arg2, arg3, \ - arg4, arg5, arg6), 0 + _gpgme_debug (lvl, "%s (%s=%p): call: " fmt "\n", \ + name, STRINGIFY (tag), (void *) (uintptr_t) tag, arg1, \ + arg2, arg3, arg4, arg5, arg6), 0 #define TRACE_ERR(err) \ err == 0 ? (TRACE_SUC ()) : \ - (_gpgme_debug (_gpgme_trace_level, "%s (%s=0x%x): error: %s <%s>\n", \ + (_gpgme_debug (_gpgme_trace_level, "%s (%s=%p): error: %s <%s>\n", \ _gpgme_trace_func, _gpgme_trace_tagname, \ _gpgme_trace_tag, gpgme_strerror (err), \ gpgme_strsource (err)), (err)) /* The cast to void suppresses GCC warnings. */ #define TRACE_SYSRES(res) \ res >= 0 ? ((void) (TRACE_SUC1 ("result=%i", res)), (res)) : \ - (_gpgme_debug (_gpgme_trace_level, "%s (%s=0x%x): error: %s\n", \ + (_gpgme_debug (_gpgme_trace_level, "%s (%s=%p): error: %s\n", \ _gpgme_trace_func, _gpgme_trace_tagname, \ _gpgme_trace_tag, strerror (errno)), (res)) #define TRACE_SYSERR(res) \ res == 0 ? ((void) (TRACE_SUC1 ("result=%i", res)), (res)) : \ - (_gpgme_debug (_gpgme_trace_level, "%s (%s=0x%x): error: %s\n", \ + (_gpgme_debug (_gpgme_trace_level, "%s (%s=%p): error: %s\n", \ _gpgme_trace_func, _gpgme_trace_tagname, \ _gpgme_trace_tag, strerror (res)), (res)) #define TRACE_SUC() \ - _gpgme_debug (_gpgme_trace_level, "%s (%s=0x%x): leave\n", \ + _gpgme_debug (_gpgme_trace_level, "%s (%s=%p): leave\n", \ _gpgme_trace_func, _gpgme_trace_tagname, \ _gpgme_trace_tag), 0 #define TRACE_SUC0(fmt) \ - _gpgme_debug (_gpgme_trace_level, "%s (%s=0x%x): leave: " fmt "\n", \ + _gpgme_debug (_gpgme_trace_level, "%s (%s=%p): leave: " fmt "\n", \ _gpgme_trace_func, _gpgme_trace_tagname, \ _gpgme_trace_tag), 0 #define TRACE_SUC1(fmt, arg1) \ - _gpgme_debug (_gpgme_trace_level, "%s (%s=0x%x): leave: " fmt "\n", \ + _gpgme_debug (_gpgme_trace_level, "%s (%s=%p): leave: " fmt "\n", \ _gpgme_trace_func, _gpgme_trace_tagname, \ _gpgme_trace_tag, arg1), 0 #define TRACE_SUC2(fmt, arg1, arg2) \ - _gpgme_debug (_gpgme_trace_level, "%s (%s=0x%x): leave: " fmt "\n", \ + _gpgme_debug (_gpgme_trace_level, "%s (%s=%p): leave: " fmt "\n", \ _gpgme_trace_func, _gpgme_trace_tagname, \ _gpgme_trace_tag, arg1, arg2), 0 #define TRACE_SUC5(fmt, arg1, arg2, arg3, arg4, arg5) \ - _gpgme_debug (_gpgme_trace_level, "%s (%s=0x%x): leave: " fmt "\n", \ + _gpgme_debug (_gpgme_trace_level, "%s (%s=%p): leave: " fmt "\n", \ _gpgme_trace_func, _gpgme_trace_tagname, \ _gpgme_trace_tag, arg1, arg2, arg3, arg4, arg5), 0 #define TRACE_LOG(fmt) \ - _gpgme_debug (_gpgme_trace_level, "%s (%s=0x%x): check: " fmt "\n", \ + _gpgme_debug (_gpgme_trace_level, "%s (%s=%p): check: " fmt "\n", \ _gpgme_trace_func, _gpgme_trace_tagname, \ _gpgme_trace_tag), 0 #define TRACE_LOG1(fmt, arg1) \ - _gpgme_debug (_gpgme_trace_level, "%s (%s=0x%x): check: " fmt "\n", \ + _gpgme_debug (_gpgme_trace_level, "%s (%s=%p): check: " fmt "\n", \ _gpgme_trace_func, _gpgme_trace_tagname, \ _gpgme_trace_tag, arg1), 0 #define TRACE_LOG2(fmt, arg1, arg2) \ - _gpgme_debug (_gpgme_trace_level, "%s (%s=0x%x): check: " fmt "\n", \ + _gpgme_debug (_gpgme_trace_level, "%s (%s=%p): check: " fmt "\n", \ _gpgme_trace_func, _gpgme_trace_tagname, \ _gpgme_trace_tag, arg1, arg2), 0 #define TRACE_LOG3(fmt, arg1, arg2, arg3) \ - _gpgme_debug (_gpgme_trace_level, "%s (%s=0x%x): check: " fmt "\n", \ + _gpgme_debug (_gpgme_trace_level, "%s (%s=%p): check: " fmt "\n", \ _gpgme_trace_func, _gpgme_trace_tagname, \ _gpgme_trace_tag, arg1, arg2, arg3), 0 #define TRACE_LOG4(fmt, arg1, arg2, arg3, arg4) \ - _gpgme_debug (_gpgme_trace_level, "%s (%s=0x%x): check: " fmt "\n", \ + _gpgme_debug (_gpgme_trace_level, "%s (%s=%p): check: " fmt "\n", \ _gpgme_trace_func, _gpgme_trace_tagname, \ _gpgme_trace_tag, arg1, arg2, arg3, arg4), 0 #define TRACE_LOG6(fmt, arg1, arg2, arg3, arg4, arg5, arg6) \ - _gpgme_debug (_gpgme_trace_level, "%s (%s=0x%x): check: " fmt "\n", \ + _gpgme_debug (_gpgme_trace_level, "%s (%s=%p): check: " fmt "\n", \ _gpgme_trace_func, _gpgme_trace_tagname, \ _gpgme_trace_tag, arg1, arg2, arg3, arg4, arg5, \ arg6), 0 #define TRACE_LOGBUF(buf, len) \ - _gpgme_debug_buffer (_gpgme_trace_level, "%s (%s=0x%x): check: %s", \ + _gpgme_debug_buffer (_gpgme_trace_level, "%s (%s=%p): check: %s", \ _gpgme_trace_func, _gpgme_trace_tagname, \ _gpgme_trace_tag, buf, len) #define TRACE_SEQ(hlp,fmt) \ _gpgme_debug_begin (&(hlp), _gpgme_trace_level, \ - "%s (%s=0x%x): check: " fmt, \ + "%s (%s=%p): check: " fmt, \ _gpgme_trace_func, _gpgme_trace_tagname, \ _gpgme_trace_tag) #define TRACE_ADD0(hlp,fmt) \ diff --git a/src/gpgme.h.in b/src/gpgme.h.in index d7d1efd1..b9f76f56 100644 --- a/src/gpgme.h.in +++ b/src/gpgme.h.in @@ -66,6 +66,14 @@ extern "C" { #define _GPGME_DEPRECATED #endif +/* The macro _GPGME_DEPRECATED_OUTSIDE_GPGME suppresses warnings for + fields we must access in GPGME for ABI compatibility. */ +#ifdef _GPGME_IN_GPGME +#define _GPGME_DEPRECATED_OUTSIDE_GPGME +#else +#define _GPGME_DEPRECATED_OUTSIDE_GPGME _GPGME_DEPRECATED +#endif + /* The version of this header should match the one of the library. Do not use this symbol in your application, use gpgme_check_version @@ -615,7 +623,7 @@ struct _gpgme_key_sig unsigned int _obsolete_class _GPGME_DEPRECATED; #else /* Must be set to SIG_CLASS below. */ - unsigned int class _GPGME_DEPRECATED; + unsigned int class _GPGME_DEPRECATED_OUTSIDE_GPGME; #endif /* The user ID string. */ @@ -1294,7 +1302,7 @@ struct _gpgme_new_signature unsigned int _obsolete_class_2; #else /* Must be set to SIG_CLASS below. */ - unsigned int class _GPGME_DEPRECATED; + unsigned int class _GPGME_DEPRECATED_OUTSIDE_GPGME; #endif /* Crypto backend specific signature class. */ diff --git a/src/keylist.c b/src/keylist.c index 2ee34b81..55351ee4 100644 --- a/src/keylist.c +++ b/src/keylist.c @@ -32,6 +32,8 @@ #include #include +/* Suppress warning for accessing deprecated member "class". */ +#define _GPGME_IN_GPGME #include "gpgme.h" #include "util.h" #include "context.h" diff --git a/src/priv-io.h b/src/priv-io.h index 7194a424..3f2f96ac 100644 --- a/src/priv-io.h +++ b/src/priv-io.h @@ -22,6 +22,7 @@ #ifndef IO_H #define IO_H +#include /* A single file descriptor passed to spawn. For child fds, dup_to specifies the fd it should become in the child, but only 0, 1 and 2 @@ -50,6 +51,7 @@ struct io_select_fd_s /* These function are either defined in posix-io.c or w32-io.c. */ void _gpgme_io_subsystem_init (void); +int _gpgme_io_connect (int fd, struct sockaddr *addr, int addrlen); int _gpgme_io_read (int fd, void *buffer, size_t count); int _gpgme_io_write (int fd, const void *buffer, size_t count); int _gpgme_io_pipe (int filedes[2], int inherit_idx); diff --git a/src/sign.c b/src/sign.c index 8405b690..03007bdf 100644 --- a/src/sign.c +++ b/src/sign.c @@ -26,6 +26,8 @@ #include #include +/* Suppress warning for accessing deprecated member "class". */ +#define _GPGME_IN_GPGME 1 #include "gpgme.h" #include "context.h" #include "ops.h" diff --git a/tests/ChangeLog b/tests/ChangeLog index fcdf1565..ab9a60aa 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,9 @@ +2009-06-22 Marcus Brinkmann + + * gpg/t-support.h (passphrase_cb): Implement write() according to + the book to silence compiler warning. + * gpgsm/t-support.h (passphrase_cb): Likewise. + 2009-06-16 Werner Koch * gpg/pgp-import.c: New. diff --git a/tests/gpg/t-support.h b/tests/gpg/t-support.h index 13475f29..6e282a34 100644 --- a/tests/gpg/t-support.h +++ b/tests/gpg/t-support.h @@ -80,7 +80,20 @@ passphrase_cb (void *opaque, const char *uid_hint, const char *passphrase_info, DWORD written; WriteFile ((HANDLE) fd, "abc\n", 4, &written, 0); #else - write (fd, "abc\n", 4); + int res; + char *pass = "abc\n"; + int passlen = strlen (pass); + int off = 0; + + do + { + res = write (fd, &pass[off], passlen - off); + if (res > 0) + off += res; + } + while (res > 0 && off != passlen); + + return off == passlen ? 0 : gpgme_error_from_errno (errno); #endif return 0; diff --git a/tests/gpgsm/t-support.h b/tests/gpgsm/t-support.h index 07f00c38..6dc14569 100644 --- a/tests/gpgsm/t-support.h +++ b/tests/gpgsm/t-support.h @@ -62,8 +62,20 @@ gpgme_error_t passphrase_cb (void *opaque, const char *uid_hint, const char *passphrase_info, int last_was_bad, int fd) { - write (fd, "abc\n", 4); - return 0; + int res; + char *pass = "abc\n"; + int passlen = strlen (pass); + int off = 0; + + do + { + res = write (fd, &pass[off], passlen - off); + if (res > 0) + off += res; + } + while (res > 0 && off != passlen); + + return off == passlen ? 0 : gpgme_error_from_errno (errno); }