Imported Upstream version 2.3.1
[platform/upstream/gpg2.git] / scd / app-p15.c
index 0530d37..0782c25 100644 (file)
@@ -522,7 +522,7 @@ cardproduct2str (card_product_t cardproduct)
   switch (cardproduct)
     {
     case CARD_PRODUCT_UNKNOWN: return "";
-    case CARD_PRODUCT_RSCS:    return "R&S";
+    case CARD_PRODUCT_RSCS:    return "RSCS";
     case CARD_PRODUCT_DTRUST:  return "D-Trust";
     }
   return "";
@@ -3703,7 +3703,7 @@ read_p15_info (app_t app)
     }
   if (!app->app_local->card_product
       && app->app_local->token_label
-      && !strncmp (app->app_local->token_label, "D-TRUST Card V3", 15)
+      && !strcmp (app->app_local->token_label, "D-TRUST Card V3")
       && app->app_local->card_type == CARD_TYPE_CARDOS_50)
     {
       app->app_local->card_product = CARD_PRODUCT_DTRUST;
@@ -3851,7 +3851,6 @@ send_certinfo (app_t app, ctrl_t ctrl, const char *certtype,
                         labelbuf, strlen (labelbuf),
                         NULL, (size_t)0);
       xfree (buf);
-      xfree (labelbuf);
     }
   return 0;
 }
@@ -4547,8 +4546,6 @@ do_getattr (app_t app, ctrl_t ctrl, const char *name)
         }
       else
         {
-          char *sn;
-
           /* We use the first private key object which has a serial
            * number set.  If none was found, we parse the first
            * object and see whether this has then a serial number.  */
@@ -4563,12 +4560,11 @@ do_getattr (app_t app, ctrl_t ctrl, const char *name)
               if (!prkdf->serial_number)
                 prkdf = NULL;
             }
-          sn = get_dispserialno (app, prkdf);
-          /* Unless there is a bogus S/N in the cert, or the product
-           * has a different strategy for the display-s/n, we should
-           * have a suitable one from the cert now.  */
-          if (sn)
+          if (prkdf)
             {
+              char *sn = get_dispserialno (app, prkdf);
+              /* Unless there is a bogus S/N in the cert we should
+               * have a suitable one from the cert here now.  */
               err = send_status_printf (ctrl, name, "%s", sn);
               xfree (sn);
               return err;
@@ -4578,13 +4574,7 @@ do_getattr (app_t app, ctrl_t ctrl, const char *name)
     }
   else if (!strcmp (name, "MANUFACTURER"))
     {
-      if (app->app_local->manufacturer_id
-          && !strchr (app->app_local->manufacturer_id, '[')
-          && app->app_local->card_product)
-        return send_status_printf (ctrl, "MANUFACTURER", "0 %s [%s]",
-                              app->app_local->manufacturer_id,
-                              cardproduct2str (app->app_local->card_product));
-      else if (app->app_local->manufacturer_id)
+      if (app->app_local->manufacturer_id)
         return send_status_printf (ctrl, "MANUFACTURER", "0 %s",
                                    app->app_local->manufacturer_id);
       else
@@ -4905,19 +4895,11 @@ static char *
 get_dispserialno (app_t app, prkdf_object_t prkdf)
 {
   char *serial;
-  size_t n;
 
   /* We prefer the SerialNumber RDN from the Subject-DN but we don't
    * use it if it features a percent sign (special character in pin
    * prompts) or has any control character.  */
-  if (app->app_local->card_product == CARD_PRODUCT_RSCS)
-    {
-      /* We use only the right 8 hex digits.  */
-      serial = app_get_serialno (app);
-      if (serial && (n=strlen (serial)) > 8)
-        memmove (serial, serial + n - 8, 9);
-    }
-  else if (prkdf && prkdf->serial_number && *prkdf->serial_number
+  if (prkdf && prkdf->serial_number && *prkdf->serial_number
       && !strchr (prkdf->serial_number, '%')
       && !any_control_or_space (prkdf->serial_number))
     {
@@ -5462,7 +5444,7 @@ do_sign (app_t app, ctrl_t ctrl, const char *keyidstr, int hashalgo,
   if (err)
     {
       log_error ("p15: MSE failed: %s\n", gpg_strerror (err));
-      goto leave;
+      return err;
     }
 
   /* Now that we have all the information available run the actual PIN
@@ -5501,7 +5483,7 @@ do_sign (app_t app, ctrl_t ctrl, const char *keyidstr, int hashalgo,
   if (err)
     {
       log_error ("p15: MSE failed: %s\n", gpg_strerror (err));
-      goto leave;
+      return err;
     }
 
   if (prkdf->keyalgo == GCRY_PK_RSA && prkdf->keynbits > 2048)