Fix gpgsm/gpg-agent bug introduced in 2.0.14.
authorWerner Koch <wk@gnupg.org>
Tue, 26 Jan 2010 13:57:30 +0000 (13:57 +0000)
committerWerner Koch <wk@gnupg.org>
Tue, 26 Jan 2010 13:57:30 +0000 (13:57 +0000)
ChangeLog
Makefile.am
patches/gnupg2-2.0.14/01-encode-s2k.patch [new file with mode: 0755]

index 7918b06..bac8f41 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2010-01-26  Werner Koch  <wk@g10code.com>
+
+       * patches/gnupg2-2.0.14/01-encode-s2k.patch: New.
+       * Makefile.am (EXTRA_DIST): Add it.
+
 2010-01-25  Werner Koch  <wk@g10code.com>
 
        * patches/gpgme-1.2.0/03-w32-socket.patch: Fix patch.
index da329aa..3b74761 100644 (file)
@@ -56,6 +56,7 @@ EXTRA_DIST = autogen.sh README.SVN ONEWS \
        patches/gnupg2-2.0.12/09-sm-keylist.patch \
        patches/gnupg2-2.0.12/10-inv-sgnr.patch \
        patches/gnupg2-2.0.12/11-photoid-sk.patch \
+       patches/gnupg2-2.0.14/01-encode-s2k.patch \
        patches/dirmngr-1.0.3/01-ldaphttp.patch \
        patches/gpgol-0.9.91/01-gpgme.patch \
         patches/gpa-0.9.0/01-title-prop.patch \
diff --git a/patches/gnupg2-2.0.14/01-encode-s2k.patch b/patches/gnupg2-2.0.14/01-encode-s2k.patch
new file mode 100755 (executable)
index 0000000..7b7896f
--- /dev/null
@@ -0,0 +1,52 @@
+#! /bin/sh
+patch -p0 -f $* < $0
+exit $?
+
+agent/
+2010-01-26  Werner Koch  <wk@g10code.com>
+
+       * protect.c (do_encryption): Encode the s2kcount and no not use a
+       static value of 96.
+
+--- agent/protect.c    (revision 5231)
++++ agent/protect.c    (working copy)
+@@ -360,19 +360,25 @@
+        
+      in canoncical format of course.  We use asprintf and %n modifier
+      and dummy values as placeholders.  */
+-  p = xtryasprintf
+-    ("(9:protected%d:%s((4:sha18:%n_8bytes_2:96)%d:%n%*s)%d:%n%*s)",
+-     (int)strlen (modestr), modestr,
+-     &saltpos, 
+-     blklen, &ivpos, blklen, "",
+-     enclen, &encpos, enclen, "");
+-  if (!p)
+-    {
+-      gpg_error_t tmperr = out_of_core ();
+-      xfree (iv);
+-      xfree (outbuf);
+-      return tmperr;
+-    }
++  {
++    char countbuf[35];
++
++    snprintf (countbuf, sizeof countbuf, "%lu", get_standard_s2k_count ());
++    p = xtryasprintf
++      ("(9:protected%d:%s((4:sha18:%n_8bytes_%u:%s)%d:%n%*s)%d:%n%*s)",
++       (int)strlen (modestr), modestr,
++       &saltpos, 
++       (unsigned int)strlen (countbuf), countbuf,
++       blklen, &ivpos, blklen, "",
++       enclen, &encpos, enclen, "");
++    if (!p)
++      {
++        gpg_error_t tmperr = out_of_core ();
++        xfree (iv);
++        xfree (outbuf);
++        return tmperr;
++      }
++  }
+   *resultlen = strlen (p);
+   *result = (unsigned char*)p;
+   memcpy (p+saltpos, iv+2*blklen, 8);
+