(modify_description): Don't increment OUT_LEN during
authorWerner Koch <wk@gnupg.org>
Tue, 15 Feb 2005 16:23:45 +0000 (16:23 +0000)
committerWerner Koch <wk@gnupg.org>
Tue, 15 Feb 2005 16:23:45 +0000 (16:23 +0000)
the second pass.

agent/ChangeLog
agent/findkey.c

index 7eb73e0..f0e19ad 100644 (file)
@@ -1,3 +1,8 @@
+2005-02-15  Werner Koch  <wk@g10code.com>
+
+       * findkey.c (modify_description): Don't increment OUT_LEN during
+       the second pass.
+
 2005-02-14  Moritz Schulte  <moritz@g10code.com>
 
        * command-ssh.c (es_read_byte): Renamed to ...
index 896cb88..1ac57ad 100644 (file)
@@ -179,18 +179,20 @@ modify_description (const char *in, const char *comment, char **result)
               switch (in[i])
                 {
                 case '%':
-                  out_len++;
                   if (out)
                     *out++ = '%';
+                  else
+                    out_len++;
                   break;
 
                 case 'c': /* Comment.  */
-                  out_len += comment_length;
-                  if (out && comment_length)
+                  if (out)
                     {
                       memcpy (out, comment, comment_length);
                       out += comment_length;
                     }
+                  else
+                    out_len += comment_length;
                   break;
 
                 default: /* Invalid special sequences are ignored.  */
@@ -199,9 +201,10 @@ modify_description (const char *in, const char *comment, char **result)
             }
           else
             {
-              out_len++;
               if (out)
                 *out++ = in[i];
+              else
+                out_len++;
             }
         }