python: Fix wrong use of write.
* lang/python/helpers.c (pyPassphraseCb): Use gpgme_io_writen. (_gpg_interact_cb): Ditto. * lang/python/helpers.h (write) [W32]: Remove bad write macro. -- GnuPG-bug-id: T6501 Using write(2) without checking for EINTR is a not a good idea. Futher gpgme_io_writen is the correct way to send data from a callback. This also fixed the wrong use of a simple macro for Windows.
This commit is contained in:
parent
e622e36f1f
commit
36a68bc530
@ -404,7 +404,7 @@ static gpgme_error_t pyPassphraseCb(void *hook,
|
|||||||
err_status = _gpg_exception2code();
|
err_status = _gpg_exception2code();
|
||||||
} else {
|
} else {
|
||||||
if (!retval) {
|
if (!retval) {
|
||||||
if (write(fd, "\n", 1) < 0) {
|
if (gpgme_io_writen (fd, "\n", 1) < 0) {
|
||||||
err_status = gpgme_error_from_syserror ();
|
err_status = gpgme_error_from_syserror ();
|
||||||
_gpg_raise_exception (err_status);
|
_gpg_raise_exception (err_status);
|
||||||
}
|
}
|
||||||
@ -439,11 +439,11 @@ static gpgme_error_t pyPassphraseCb(void *hook,
|
|||||||
goto leave;
|
goto leave;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (write(fd, buf, len) < 0) {
|
if (gpgme_io_writen (fd, buf, len) < 0) {
|
||||||
err_status = gpgme_error_from_syserror ();
|
err_status = gpgme_error_from_syserror ();
|
||||||
_gpg_raise_exception (err_status);
|
_gpg_raise_exception (err_status);
|
||||||
}
|
}
|
||||||
if (! err_status && write(fd, "\n", 1) < 0) {
|
if (! err_status && gpgme_io_writen (fd, "\n", 1) < 0) {
|
||||||
err_status = gpgme_error_from_syserror ();
|
err_status = gpgme_error_from_syserror ();
|
||||||
_gpg_raise_exception (err_status);
|
_gpg_raise_exception (err_status);
|
||||||
}
|
}
|
||||||
@ -761,11 +761,11 @@ _gpg_interact_cb(void *opaque, const char *keyword,
|
|||||||
goto leave;
|
goto leave;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (write(fd, buffer, size) < 0) {
|
if (gpgme_io_writen (fd, buffer, size) < 0) {
|
||||||
err_status = gpgme_error_from_syserror ();
|
err_status = gpgme_error_from_syserror ();
|
||||||
_gpg_raise_exception (err_status);
|
_gpg_raise_exception (err_status);
|
||||||
}
|
}
|
||||||
if (! err_status && write(fd, "\n", 1) < 0) {
|
if (! err_status && gpgme_io_writen (fd, "\n", 1) < 0) {
|
||||||
err_status = gpgme_error_from_syserror ();
|
err_status = gpgme_error_from_syserror ();
|
||||||
_gpg_raise_exception (err_status);
|
_gpg_raise_exception (err_status);
|
||||||
}
|
}
|
||||||
|
@ -25,11 +25,6 @@
|
|||||||
#include <gpgme.h>
|
#include <gpgme.h>
|
||||||
#include "Python.h"
|
#include "Python.h"
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
#include <windows.h>
|
|
||||||
#define write(fd, str, sz) {DWORD written; WriteFile((HANDLE) fd, str, sz, &written, 0);}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Flag specifying whether this is an in-tree build. */
|
/* Flag specifying whether this is an in-tree build. */
|
||||||
extern int gpg_in_tree_build;
|
extern int gpg_in_tree_build;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user