[pkg-opensc-commit] [opensc] 02/02: Add upstream patch to fix interaction with DNIe UI

Eric Dorland eric at moszumanska.debian.org
Mon Jan 16 00:26:38 UTC 2017


This is an automated email from the git hooks/post-receive script.

eric pushed a commit to branch master
in repository opensc.

commit f9001c992fc0d33eff99a3a5c02641c25444c2ee
Author: Eric Dorland <eric at debian.org>
Date:   Sun Jan 15 19:19:23 2017 -0500

    Add upstream patch to fix interaction with DNIe UI
    
    Closes: 826524
---
 debian/changelog                                   |  4 +-
 .../0001-Fix-interaction-with-DNIe-UI.patch        | 91 ++++++++++++++++++++++
 debian/patches/series                              |  1 +
 3 files changed, 95 insertions(+), 1 deletion(-)

diff --git a/debian/changelog b/debian/changelog
index 5036e68..0672c56 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,8 +2,10 @@ opensc (0.16.0-3) unstable; urgency=medium
 
   * debian/opensc-pkcs11.install, debian/opensc-pkcs11.module: Add p11-kit
     module file. Thanks Timo Aaltonen. (Closes: #835029)
+  * debian/patches/0001-Fix-interaction-with-DNIe-UI.patch: Add upstream
+    patch to fix interaction with DNIe UI. (Closes: #826524)
 
- --
+ -- Eric Dorland <eric at debian.org>  Sun, 15 Jan 2017 19:18:44 -0500
 
 opensc (0.16.0-2) unstable; urgency=medium
 
diff --git a/debian/patches/0001-Fix-interaction-with-DNIe-UI.patch b/debian/patches/0001-Fix-interaction-with-DNIe-UI.patch
new file mode 100644
index 0000000..89533ff
--- /dev/null
+++ b/debian/patches/0001-Fix-interaction-with-DNIe-UI.patch
@@ -0,0 +1,91 @@
+From: Javier Serrano Polo <javier at jasp.net>
+Date: Sun, 15 Jan 2017 18:56:16 -0500
+Subject: Fix interaction with DNIe UI
+
+The interaction with the DNIe UI does not work on Firefox because an alarm
+interrupts the read operations, aborting the confirmation. This is fixed by
+using nointr_fgets(). There are side issues:
+* Forked process should abort on failure instead of continuing with OpenSC.
+* Useless initializations with memset().
+* Size adjustments in read and write operations.
+
+Forwarded: https://github.com/OpenSC/OpenSC/pull/789
+---
+ src/libopensc/card-dnie.c | 42 +++++++++++++++++++++++++++++++-----------
+ 1 file changed, 31 insertions(+), 11 deletions(-)
+
+diff --git a/src/libopensc/card-dnie.c b/src/libopensc/card-dnie.c
+index 771becd6..beec8b5c 100644
+--- a/src/libopensc/card-dnie.c
++++ b/src/libopensc/card-dnie.c
+@@ -162,6 +162,25 @@ const char *user_consent_message="Esta a punto de realizar una firma digital\nco
+ char *user_consent_msgs[] = { "SETTITLE", "SETDESC", "CONFIRM", "BYE" };
+ 
+ /**
++ * Do fgets() without interruptions.
++ *
++ * Retry the operation if it is interrupted, such as with receiving an alarm.
++ *
++ * @param s Buffer receiving the data
++ * @param size Size of the buffer
++ * @param stream Stream to read
++ * @return s on success, NULL on error
++ */
++static char *nointr_fgets(char *s, int size, FILE *stream)
++{
++	while (fgets(s, size, stream) == NULL) {
++		if (feof(stream) || errno != EINTR)
++			return NULL;
++	}
++	return s;
++}
++
++/**
+  * Ask for user consent.
+  *
+  * Check for user consent configuration,
+@@ -283,9 +302,8 @@ int dnie_ask_user_consent(struct sc_card * card, const char *title, const char *
+ 		/* call exec() with proper user_consent_app from configuration */
+ 		/* if ok should never return */
+ 		execlp(GET_DNIE_UI_CTX(card).user_consent_app, GET_DNIE_UI_CTX(card).user_consent_app, (char *)NULL);
+-		res = SC_ERROR_INTERNAL;
+-		msg = "execlp() error";	/* exec() failed */
+-		goto do_error;
++		sc_log(card->ctx, "execlp() error");
++		abort();
+ 	default:		/* parent */
+ 		/* Close the pipe ends that the child uses to read from / write to
+ 		 * so when we close the others, an EOF will be transmitted properly.
+@@ -304,22 +322,24 @@ int dnie_ask_user_consent(struct sc_card * card, const char *title, const char *
+ 			goto do_error;
+ 		}
+ 		/* read and ignore first line */
+-		fflush(stdin);
++		if (nointr_fgets(buf, sizeof(buf), fin) == NULL) {
++			res = SC_ERROR_INTERNAL;
++			msg = "nointr_fgets() Unexpected IOError/EOF";
++			goto do_error;
++		}
+ 		for (n = 0; n<4; n++) {
+ 			char *pt;
+-			memset(outbuf, 0, sizeof(outbuf));
+-			if (n==0) snprintf(outbuf,1023,"%s %s\n",user_consent_msgs[0],title);
+-			else if (n==1) snprintf(outbuf,1023,"%s %s\n",user_consent_msgs[1],message);
+-			else snprintf(outbuf,1023,"%s\n",user_consent_msgs[n]);
++			if (n==0) snprintf(outbuf, sizeof outbuf,"%s %s\n",user_consent_msgs[0],title);
++			else if (n==1) snprintf(outbuf, sizeof outbuf,"%s %s\n",user_consent_msgs[1],message);
++			else snprintf(outbuf, sizeof outbuf,"%s\n",user_consent_msgs[n]);
+ 			/* send message */
+ 			fputs(outbuf, fout);
+ 			fflush(fout);
+ 			/* get response */
+-			memset(buf, 0, sizeof(buf));
+-			pt=fgets(buf, sizeof(buf) - 1, fin);
++			pt=nointr_fgets(buf, sizeof(buf), fin);
+ 			if (pt==NULL) {
+ 				res = SC_ERROR_INTERNAL;
+-				msg = "fgets() Unexpected IOError/EOF";
++				msg = "nointr_fgets() Unexpected IOError/EOF";
+ 				goto do_error;
+ 			}
+ 			if (strstr(buf, "OK") == NULL) {
diff --git a/debian/patches/series b/debian/patches/series
new file mode 100644
index 0000000..42247f2
--- /dev/null
+++ b/debian/patches/series
@@ -0,0 +1 @@
+0001-Fix-interaction-with-DNIe-UI.patch

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-opensc/opensc.git



More information about the pkg-opensc-commit mailing list