[Spice-devel] [PATCH] Do not use static buffer to avoid possible races

Christophe Fergeau cfergeau at redhat.com
Fri Aug 17 14:20:05 UTC 2018


Good catch, and the buffer is small enough that it's not a big deal if
it's not static, and the data it contains is copied in this same block,
so we don't need the buffer to stay alive for a prolonged time.

Acked-by: Christophe Fergeau <cfergeau at redhat.com>


On Tue, Aug 14, 2018 at 10:35:56AM +0100, Frediano Ziglio wrote:
> Using a static writeable buffer and threads could lead to race
> conditions (like multiple threads calling the same function).
> The fci_template buffer is changed some lines below with a memcpy.
> 
> Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
> ---
>  src/card_7816.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/card_7816.c b/src/card_7816.c
> index 58bdda8..dc12138 100644
> --- a/src/card_7816.c
> +++ b/src/card_7816.c
> @@ -659,7 +659,7 @@ vcard7816_vm_process_apdu(VCard *card, VCardAPDU *apdu,
>                  *response = vcard_response_new(card, gp_response,
>                      sizeof(gp_response), apdu->a_Le, VCARD7816_STATUS_SUCCESS);
>              } else {
> -                static unsigned char fci_template[] = {
> +                unsigned char fci_template[] = {
>                      0x6F, 0x0B, 0x84, 0x07, 0xA0, 0x00, 0x00, 0x00,
>                      0x79, 0x03, 0x00, 0xA5, 0x00};
>                  /* with GSC-IS 2 applets, we do not need to return anything
> -- 
> 2.17.1
> 
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20180817/e4559c3a/attachment.sig>


More information about the Spice-devel mailing list