scd: Fix int/short mismatch in format string of app-p15.c

* scd/app-p15.c (parse_certid): Use snprintf and cast value.
(send_certinfo): Ditto.
(send_keypairinfo): Ditto.
(do_getattr): Ditto.
This commit is contained in:
Werner Koch 2014-09-18 15:39:50 +02:00
parent f82a6e0f08
commit b17e8bbf20
1 changed files with 8 additions and 4 deletions

View File

@ -494,7 +494,8 @@ parse_certid (app_t app, const char *certid,
*r_objidlen = 0;
if (app->app_local->home_df)
sprintf (tmpbuf, "P15-%04hX.", (app->app_local->home_df & 0xffff));
snprintf (tmpbuf, sizeof tmpbuf,
"P15-%04X.", (unsigned int)(app->app_local->home_df & 0xffff));
else
strcpy (tmpbuf, "P15.");
if (strncmp (certid, tmpbuf, strlen (tmpbuf)) )
@ -2370,7 +2371,8 @@ send_certinfo (app_t app, ctrl_t ctrl, const char *certtype,
p = stpcpy (buf, "P15");
if (app->app_local->home_df)
{
sprintf (p, "-%04hX", (app->app_local->home_df & 0xffff));
snprintf (p, 6, "-%04X",
(unsigned int)(app->app_local->home_df & 0xffff));
p += 5;
}
p = stpcpy (p, ".");
@ -2461,7 +2463,8 @@ send_keypairinfo (app_t app, ctrl_t ctrl, prkdf_object_t keyinfo)
p = stpcpy (buf, "P15");
if (app->app_local->home_df)
{
sprintf (p, "-%04hX", (app->app_local->home_df & 0xffff));
snprintf (p, 6, "-%04hX",
(unsigned int)(app->app_local->home_df & 0xffff));
p += 5;
}
p = stpcpy (p, ".");
@ -2686,7 +2689,8 @@ do_getattr (app_t app, ctrl_t ctrl, const char *name)
p = stpcpy (buf, "P15");
if (app->app_local->home_df)
{
sprintf (p, "-%04hX", (app->app_local->home_df & 0xffff));
snprintf (p, 6, "-%04hX",
(unsigned int)(app->app_local->home_df & 0xffff));
p += 5;
}
p = stpcpy (p, ".");