diff mbox series

[1/3] package/opensc: new package

Message ID 20211203083707.1741283-1-jose.pekkarinen@unikie.com
State Superseded
Headers show
Series [1/3] package/opensc: new package | expand

Commit Message

José Pekkarinen Dec. 3, 2021, 8:37 a.m. UTC
The patch will add a basic opensc package to build
on buildroot.

Signed-off-by: José Pekkarinen <jose.pekkarinen@unikie.com>
---
 DEVELOPERS                                    |   1 +
 package/Config.in                             |   1 +
 ...ckage-opensc-fix-maybe-uninitialized.patch |  69 +++++++++
 ...x-strict-aliasing-warnings-as-errors.patch | 140 ++++++++++++++++++
 package/opensc/Config.in                      |  11 ++
 package/opensc/opensc.hash                    |   5 +
 package/opensc/opensc.mk                      |  14 ++
 7 files changed, 241 insertions(+)
 create mode 100644 package/opensc/0001-package-opensc-fix-maybe-uninitialized.patch
 create mode 100644 package/opensc/0002-package-opensc-fix-strict-aliasing-warnings-as-errors.patch
 create mode 100644 package/opensc/Config.in
 create mode 100644 package/opensc/opensc.hash
 create mode 100644 package/opensc/opensc.mk

Comments

José Pekkarinen Dec. 10, 2021, 6:20 a.m. UTC | #1
Hi,

Any comments in the following patchset?

Thanks!

José


On Fri, Dec 3, 2021 at 10:37 AM José Pekkarinen <jose.pekkarinen@unikie.com>
wrote:

> The patch will add a basic opensc package to build
> on buildroot.
>
> Signed-off-by: José Pekkarinen <jose.pekkarinen@unikie.com>
> ---
>  DEVELOPERS                                    |   1 +
>  package/Config.in                             |   1 +
>  ...ckage-opensc-fix-maybe-uninitialized.patch |  69 +++++++++
>  ...x-strict-aliasing-warnings-as-errors.patch | 140 ++++++++++++++++++
>  package/opensc/Config.in                      |  11 ++
>  package/opensc/opensc.hash                    |   5 +
>  package/opensc/opensc.mk                      |  14 ++
>  7 files changed, 241 insertions(+)
>  create mode 100644
> package/opensc/0001-package-opensc-fix-maybe-uninitialized.patch
>  create mode 100644
> package/opensc/0002-package-opensc-fix-strict-aliasing-warnings-as-errors.patch
>  create mode 100644 package/opensc/Config.in
>  create mode 100644 package/opensc/opensc.hash
>  create mode 100644 package/opensc/opensc.mk
>
> diff --git a/DEVELOPERS b/DEVELOPERS
> index 70262eac8c..d92c38f07d 100644
> --- a/DEVELOPERS
> +++ b/DEVELOPERS
> @@ -1455,6 +1455,7 @@ F:        support/testing/tests/package/test_zfs.py
>
>  N:     José Pekkarinen <jose.pekkarinen@unikie.com>
>  F:     package/softhsm2/
> +F:     package/opensc/
>
>  N:     Joseph Kogut <joseph.kogut@gmail.com>
>  F:     package/at-spi2-atk/
> diff --git a/package/Config.in b/package/Config.in
> index e355ab1987..3cfcf372f3 100644
> --- a/package/Config.in
> +++ b/package/Config.in
> @@ -1617,6 +1617,7 @@ menu "Hardware handling"
>         source "package/tslib/Config.in"
>         source "package/uhd/Config.in"
>         source "package/urg/Config.in"
> +       source "package/opensc/Config.in"
>  endmenu
>
>  menu "Javascript"
> diff --git
> a/package/opensc/0001-package-opensc-fix-maybe-uninitialized.patch
> b/package/opensc/0001-package-opensc-fix-maybe-uninitialized.patch
> new file mode 100644
> index 0000000000..1f6a2e6f42
> --- /dev/null
> +++ b/package/opensc/0001-package-opensc-fix-maybe-uninitialized.patch
> @@ -0,0 +1,69 @@
> +package:opensc: Fix maybe uninitialized issues
> +
> +This patch will fix some warning treated as errors
> +that highlight maybe uninitialized variables.
> +
> +Signed-off-by: José Pekkarinen <jose.pekkarinen@unikie.com>
> +Index: opensc-0.22.0/src/pkcs15init/pkcs15-asepcos.c
> +===================================================================
> +--- opensc-0.22.0.orig/src/pkcs15init/pkcs15-asepcos.c
> ++++ opensc-0.22.0/src/pkcs15init/pkcs15-asepcos.c
> +@@ -221,7 +221,7 @@ static int asepcos_do_store_pin(sc_profi
> + {
> +       sc_file_t *nfile = NULL;
> +       u8  buf[64], sbuf[64], *p = buf, *q = sbuf;
> +-      int r, akn;
> ++      int r, akn = 0;
> +
> +       if (auth_info->auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN)
> +               return SC_ERROR_OBJECT_NOT_VALID;
> +Index: opensc-0.22.0/src/libopensc/pkcs15-coolkey.c
> +===================================================================
> +--- opensc-0.22.0.orig/src/libopensc/pkcs15-coolkey.c
> ++++ opensc-0.22.0/src/libopensc/pkcs15-coolkey.c
> +@@ -147,9 +147,9 @@ coolkey_find_matching_cert(sc_card_t *ca
> + static int
> + coolkey_get_attribute_ulong(sc_card_t *card, sc_cardctl_coolkey_object_t
> *obj, CK_ATTRIBUTE_TYPE type, CK_ULONG *value)
> + {
> +-      const u8 *val;
> +-      size_t val_len;
> +-      u8 data_type;
> ++      const u8 *val = malloc(sizeof(u8));
> ++      size_t val_len = 0;
> ++      u8 data_type = 0;
> +       int r;
> +
> +       r  = coolkey_get_attribute(card, obj, type, &val, &val_len,
> &data_type);
> +@@ -168,8 +168,8 @@ static int
> + coolkey_get_attribute_boolean(sc_card_t *card,
> sc_cardctl_coolkey_object_t *obj, CK_ATTRIBUTE_TYPE attr_type)
> + {
> +       int r;
> +-      const u8 *val;
> +-      size_t val_len;
> ++      const u8 *val = malloc(sizeof(u8));
> ++      size_t val_len = 0;
> +
> +       r = coolkey_get_attribute(card, obj, attr_type, &val, &val_len,
> NULL);
> +       if (r < 0) {
> +@@ -186,7 +186,7 @@ static int
> + coolkey_get_attribute_bytes(sc_card_t *card, sc_cardctl_coolkey_object_t
> *obj, CK_ATTRIBUTE_TYPE type, u8 *data, size_t *data_len, size_t
> max_data_len)
> + {
> +       const u8 *val;
> +-      size_t val_len;
> ++      size_t val_len = 0;
> +       int r;
> +
> +       r = coolkey_get_attribute(card, obj, type, &val, &val_len, NULL);
> +Index: opensc-0.22.0/src/tools/opensc-explorer.c
> +===================================================================
> +--- opensc-0.22.0.orig/src/tools/opensc-explorer.c
> ++++ opensc-0.22.0/src/tools/opensc-explorer.c
> +@@ -2472,7 +2472,7 @@ int main(int argc, char *argv[])
> +               char *line;
> +               int cargc;
> +               char *cargv[260];
> +-              int multiple;
> ++              int multiple = 0;
> +               struct command *cmd;
> +               char prompt[3*SC_MAX_PATH_STRING_SIZE];
> +
> diff --git
> a/package/opensc/0002-package-opensc-fix-strict-aliasing-warnings-as-errors.patch
> b/package/opensc/0002-package-opensc-fix-strict-aliasing-warnings-as-errors.patch
> new file mode 100644
> index 0000000000..194f7c4305
> --- /dev/null
> +++
> b/package/opensc/0002-package-opensc-fix-strict-aliasing-warnings-as-errors.patch
> @@ -0,0 +1,140 @@
> +
> +package/opensc: fix strict aliasing warnings as errors
> +
> +Building under sourcery-arm toolchain it is possible
> +to find multiple of these warnings as errors, this patch
> +will adress them
> +
> +Signed-off-by: José Pekkarinen <jose.pekkarinen@unikie.com>
> +Index: opensc-0.22.0/src/libopensc/card-gids.c
> +===================================================================
> +--- opensc-0.22.0.orig/src/libopensc/card-gids.c
> ++++ opensc-0.22.0/src/libopensc/card-gids.c
> +@@ -691,7 +691,8 @@ static int gids_finish(sc_card_t *card)
> + // the cmap file is used to detect the key algorithm / size
> + static int gids_get_crypto_identifier_from_key_ref(sc_card_t *card,
> const unsigned char keyref, unsigned char *cryptoidentifier) {
> +       struct gids_private_data *data = (struct gids_private_data *)
> card->drv_data;
> +-      PCONTAINER_MAP_RECORD records = (PCONTAINER_MAP_RECORD)
> data->cmapfile;
> ++      PCONTAINER_MAP_RECORD records =
> malloc(sizeof(CONTAINER_MAP_RECORD));
> ++      memcpy(records, data->cmapfile, sizeof(CONTAINER_MAP_RECORD));
> +       int recordsnum = (int) (data->cmapfilesize /
> sizeof(CONTAINER_MAP_RECORD));
> +       int index = keyref - GIDS_FIRST_KEY_IDENTIFIER;
> +       if (index >= recordsnum) {
> +@@ -1112,10 +1113,10 @@ gids_get_all_containers(sc_card_t* card,
> + // return the detail about a container to emulate a pkcs15 card
> + static int
> + gids_get_container_detail(sc_card_t* card,
> sc_cardctl_gids_get_container_t* container) {
> +-      PCONTAINER_MAP_RECORD records = NULL;
> ++      PCONTAINER_MAP_RECORD records =
> malloc(sizeof(CONTAINER_MAP_RECORD));
> +       struct gids_private_data *privatedata = (struct gids_private_data
> *) card->drv_data;
> +       size_t recordsnum, num, i;
> +-      records = (PCONTAINER_MAP_RECORD) privatedata ->cmapfile;
> ++      memcpy(records, privatedata->cmapfile,
> sizeof(CONTAINER_MAP_RECORD));
> +       recordsnum = (privatedata ->cmapfilesize /
> sizeof(CONTAINER_MAP_RECORD));
> +
> +       num = container->containernum ;
> +@@ -1158,7 +1159,8 @@ gids_get_container_detail(sc_card_t* car
> + static int
> + gids_select_key_reference(sc_card_t *card, sc_pkcs15_prkey_info_t*
> key_info) {
> +       struct gids_private_data *data = (struct gids_private_data *)
> card->drv_data;
> +-      PCONTAINER_MAP_RECORD records = (PCONTAINER_MAP_RECORD)
> data->cmapfile;
> ++      PCONTAINER_MAP_RECORD records =
> malloc(sizeof(CONTAINER_MAP_RECORD));
> ++      memcpy(records, data->cmapfile, sizeof(CONTAINER_MAP_RECORD));
> +       size_t recordsnum;
> +       int r;
> +       char ch_tmp[10];
> +@@ -1302,7 +1304,8 @@ static int gids_create_keyfile(sc_card_t
> +       struct gids_private_data *data = (struct gids_private_data *)
> card->drv_data;
> +       size_t recordnum;
> +       size_t containernum = key_info->key_reference -
> GIDS_FIRST_KEY_IDENTIFIER;
> +-      PCONTAINER_MAP_RECORD records = ((PCONTAINER_MAP_RECORD)
> cmapbuffer) + containernum;
> ++      PCONTAINER_MAP_RECORD records =
> malloc(sizeof(CONTAINER_MAP_RECORD));
> ++      memcpy(records, cmapbuffer + containernum,
> sizeof(CONTAINER_MAP_RECORD));
> +       struct gids_keymap_record* keymaprecord = NULL;
> +       int i;
> +
> +@@ -1390,12 +1393,12 @@ static int gids_create_keyfile(sc_card_t
> +
> +       // convert char to wchar
> +       for(i = 0; i < MAX_CONTAINER_NAME_LEN && object->label[i]; i++) {
> +-              records->wszGuid[i] = object->label[i];
> ++              records->wszGuid[i] = (unsigned short) object->label[i];
> +       }
> +
> +       // TODO: check if a container with the same name already exists
> and prevent is creation or change its name
> +
> +-      records->bFlags = CONTAINER_MAP_VALID_CONTAINER;
> ++      records->bFlags = (unsigned char) CONTAINER_MAP_VALID_CONTAINER;
> +       if (recordnum == 0) {
> +               records->bFlags |= CONTAINER_MAP_DEFAULT_CONTAINER;
> +       }
> +@@ -1638,7 +1641,8 @@ static int gids_delete_container_num(sc_
> +       size_t keymaprecordnum = 0;
> +       struct gids_private_data *data = (struct gids_private_data *)
> card->drv_data;
> +       size_t recordnum;
> +-      PCONTAINER_MAP_RECORD records = ((PCONTAINER_MAP_RECORD)
> cmapbuffer) + containernum;
> ++      PCONTAINER_MAP_RECORD records =
> malloc(sizeof(CONTAINER_MAP_RECORD));
> ++      memcpy(records, cmapbuffer + containernum,
> sizeof(CONTAINER_MAP_RECORD));
> +       struct gids_keymap_record* keymaprecord = NULL;
> +
> +       SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
> +Index: opensc-0.22.0/src/libopensc/card-gpk.c
> +===================================================================
> +--- opensc-0.22.0.orig/src/libopensc/card-gpk.c
> ++++ opensc-0.22.0/src/libopensc/card-gpk.c
> +@@ -228,11 +228,12 @@ static int
> + match_path(sc_card_t *card, unsigned short int **pathptr, size_t
> *pathlen,
> +               int need_info)
> + {
> +-      unsigned short int      *curptr, *ptr;
> ++      u8                      *curptr;
> ++      unsigned short int      *ptr;
> +       size_t          curlen, len;
> +       size_t          i;
> +
> +-      curptr = (unsigned short int *) card->cache.current_path.value;
> ++      curptr = (u8 *) card->cache.current_path.value;
> +       curlen = card->cache.current_path.len;
> +       ptr    = *pathptr;
> +       len    = *pathlen;
> +@@ -242,7 +243,7 @@ match_path(sc_card_t *card, unsigned sho
> +
> +       /* Make sure path starts with MF.
> +        * Note the cached path should always begin with MF. */
> +-      if (ptr[0] != GPK_FID_MF || curptr[0] != GPK_FID_MF)
> ++      if (ptr[0] != (GPK_FID_MF >> 8) || curptr[0] != (GPK_FID_MF >> 8))
> +               return 0;
> +
> +       for (i = 1; i < len && i < curlen; i++) {
> +@@ -545,7 +546,7 @@ gpk_select_id(sc_card_t *card, int kind,
> +       /* Fix up the path cache.
> +        * NB we never cache the ID of an EF, just the DF path */
> +       if (r == 0) {
> +-              unsigned short int      *path;
> ++              u8      *path;
> +
> +               switch (kind) {
> +               case GPK_SEL_MF:
> +@@ -555,7 +556,7 @@ gpk_select_id(sc_card_t *card, int kind,
> +                       if (cp->len + 1 > SC_MAX_PATH_SIZE / 2) {
> +                               return SC_ERROR_INTERNAL;
> +                       }
> +-                      path = (unsigned short int *) cp->value;
> ++                      path = (u8 *) cp->value;
> +                       path[cp->len++] = fid;
> +               }
> +       } else {
> +Index: opensc-0.22.0/src/tools/gids-tool.c
> +===================================================================
> +--- opensc-0.22.0.orig/src/tools/gids-tool.c
> ++++ opensc-0.22.0/src/tools/gids-tool.c
> +@@ -401,7 +401,8 @@ static int print_info(sc_card_t *card) {
> +               if (cmapfilesize == sizeof(cmapfile)) {
> +                       printf("Unable to find the container file
> (mscp\\cmapfile)\n");
> +               } else {
> +-                      PCONTAINER_MAP_RECORD cmaprecords =
> (PCONTAINER_MAP_RECORD) cmapfile;
> ++                      PCONTAINER_MAP_RECORD cmaprecords =
> malloc(sizeof(CONTAINER_MAP_RECORD));
> ++                      memcpy(cmaprecords, cmapfile,
> sizeof(CONTAINER_MAP_RECORD));
> +                       int cmaprecordnum = (cmapfilesize /
> sizeof(CONTAINER_MAP_RECORD));
> +                       int keymaprecordnum = -1;
> +                       struct gids_keymap_record* keymaprecord = ((struct
> gids_keymap_record*)(keymap +1));
> diff --git a/package/opensc/Config.in b/package/opensc/Config.in
> new file mode 100644
> index 0000000000..d6b137a87f
> --- /dev/null
> +++ b/package/opensc/Config.in
> @@ -0,0 +1,11 @@
> +config BR2_PACKAGE_OPENSC
> +       bool "opensc"
> +       depends on !BR2_STATIC_LIBS # dlopen()
> +       select BR2_PACKAGE_PCSC_LITE
> +       select BR2_PACKAGE_OPENSSL
> +       select BR2_PACKAGE_OPENSSL_FORCE_LIBOPENSSL
> +       help
> +         OpenSC provides a set of libraries and utilities to work
> +         with smart cards.
> +
> +         https://github.com/OpenSC/OpenSC/wiki
> diff --git a/package/opensc/opensc.hash b/package/opensc/opensc.hash
> new file mode 100644
> index 0000000000..1e3472ba2a
> --- /dev/null
> +++ b/package/opensc/opensc.hash
> @@ -0,0 +1,5 @@
> +# From https://https://github.com/OpenSC/OpenSC/releases/
> +sha256  8d4e5347195ebea332be585df61dcc470331c26969e4b0447c851fb0844c7186
> opensc-0.22.0.tar.gz
> +
> +# Computed locally
> +sha256  376b54d4c5f4aa99421823fa4da93e3ab73096fce2400e89858632aa7da24a14
> COPYING
> diff --git a/package/opensc/opensc.mk b/package/opensc/opensc.mk
> new file mode 100644
> index 0000000000..7221eee944
> --- /dev/null
> +++ b/package/opensc/opensc.mk
> @@ -0,0 +1,14 @@
>
> +################################################################################
> +#
> +# opensc
> +#
>
> +################################################################################
> +
> +OPENSC_VERSION = 0.22.0
> +OPENSC_SITE =
> https://github.com/OpenSC/OpenSC/releases/download/$(OPENSC_VERSION)
> +OPENSC_LICENSE = LGPL-2.1+
> +OPENSC_LICENSE_FILES = COPYING
> +OPENSC_DEPENDENCIES = openssl pcsc-lite
> +OPENSC_INSTALL_STAGING = YES
> +
> +$(eval $(autotools-package))
> --
> 2.30.2
>
>
Giulio Benetti Dec. 10, 2021, 10:29 a.m. UTC | #2
Hi José,

please use plain-text,

On 10/12/21 07:20, José Pekkarinen wrote:
> 
>     Hi,
> 
>     Any comments in the following patchset?
> 
>     Thanks!
> 
>     José
> 
> 
> On Fri, Dec 3, 2021 at 10:37 AM José Pekkarinen 

Only 1 week has passed, backlog is pretty big(478 patches at the moment)

> <jose.pekkarinen@unikie.com <mailto:jose.pekkarinen@unikie.com>> wrote:
> 
>     The patch will add a basic opensc package to build
>     on buildroot.

This commit log is not sufficient. Can you please take a look at other 
commit log on while adding a "new package"? Try to imitate, that's a 
good starting point.

>     Signed-off-by: José Pekkarinen <jose.pekkarinen@unikie.com
>     <mailto:jose.pekkarinen@unikie.com>>

This ^^^ SoB has a strange format, how did you produce the patch?
Also how did you set the user.email in git?

>     ---
>       DEVELOPERS                                    |   1 +
>       package/Config.in                             |   1 +
>       ...ckage-opensc-fix-maybe-uninitialized.patch |  69 +++++++++
>       ...x-strict-aliasing-warnings-as-errors.patch | 140 ++++++++++++++++++
>       package/opensc/Config.in                      |  11 ++
>       package/opensc/opensc.hash                    |   5 +
>       package/opensc/opensc.mk <http://opensc.mk>                     
>     |  14 ++
>       7 files changed, 241 insertions(+)
>       create mode 100644
>     package/opensc/0001-package-opensc-fix-maybe-uninitialized.patch
>       create mode 100644
>     package/opensc/0002-package-opensc-fix-strict-aliasing-warnings-as-errors.patch
>       create mode 100644 package/opensc/Config.in
>       create mode 100644 package/opensc/opensc.hash
>       create mode 100644 package/opensc/opensc.mk <http://opensc.mk>
> 
>     diff --git a/DEVELOPERS b/DEVELOPERS
>     index 70262eac8c..d92c38f07d 100644
>     --- a/DEVELOPERS
>     +++ b/DEVELOPERS
>     @@ -1455,6 +1455,7 @@ F:       
>     support/testing/tests/package/test_zfs.py
> 
>       N:     José Pekkarinen <jose.pekkarinen@unikie.com
>     <mailto:jose.pekkarinen@unikie.com>>
>       F:     package/softhsm2/
>     +F:     package/opensc/

Here you need to alphabetize

> 
>       N:     Joseph Kogut <joseph.kogut@gmail.com
>     <mailto:joseph.kogut@gmail.com>>
>       F:     package/at-spi2-atk/
>     diff --git a/package/Config.in b/package/Config.in
>     index e355ab1987..3cfcf372f3 100644
>     --- a/package/Config.in
>     +++ b/package/Config.in
>     @@ -1617,6 +1617,7 @@ menu "Hardware handling"
>              source "package/tslib/Config.in"
>              source "package/uhd/Config.in"
>              source "package/urg/Config.in"
>     +       source "package/opensc/Config.in"

Ditto

>       endmenu
> 
>       menu "Javascript"
>     diff --git

How have you created this patch? Have you used git format-patch -s -M?
It seems not

>     a/package/opensc/0001-package-opensc-fix-maybe-uninitialized.patch
>     b/package/opensc/0001-package-opensc-fix-maybe-uninitialized.patch
>     new file mode 100644
>     index 0000000000..1f6a2e6f42
>     --- /dev/null
>     +++ b/package/opensc/0001-package-opensc-fix-maybe-uninitialized.patch
>     @@ -0,0 +1,69 @@
>     +package:opensc: Fix maybe uninitialized issues

Here ^^^ you need to have a commit log referred to opensc not to 
buildroot. You have to talk about what happens in opensc not in buildroot.

>     +
>     +This patch will fix some warning treated as errors
>     +that highlight maybe uninitialized variables.
>     +
>     +Signed-off-by: José Pekkarinen <jose.pekkarinen@unikie.com
>     <mailto:jose.pekkarinen@unikie.com>>

SoB Ditto

>     +Index: opensc-0.22.0/src/pkcs15init/pkcs15-asepcos.c
>     +===================================================================
>     +--- opensc-0.22.0.orig/src/pkcs15init/pkcs15-asepcos.c
>     ++++ opensc-0.22.0/src/pkcs15init/pkcs15-asepcos.c
>     +@@ -221,7 +221,7 @@ static int asepcos_do_store_pin(sc_profi
>     + {
>     +       sc_file_t *nfile = NULL;
>     +       u8  buf[64], sbuf[64], *p = buf, *q = sbuf;
>     +-      int r, akn;
>     ++      int r, akn = 0;
>     +
>     +       if (auth_info->auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN)
>     +               return SC_ERROR_OBJECT_NOT_VALID;
>     +Index: opensc-0.22.0/src/libopensc/pkcs15-coolkey.c
>     +===================================================================
>     +--- opensc-0.22.0.orig/src/libopensc/pkcs15-coolkey.c
>     ++++ opensc-0.22.0/src/libopensc/pkcs15-coolkey.c
>     +@@ -147,9 +147,9 @@ coolkey_find_matching_cert(sc_card_t *ca
>     + static int
>     + coolkey_get_attribute_ulong(sc_card_t *card,
>     sc_cardctl_coolkey_object_t *obj, CK_ATTRIBUTE_TYPE type, CK_ULONG
>     *value)
>     + {
>     +-      const u8 *val;
>     +-      size_t val_len;
>     +-      u8 data_type;
>     ++      const u8 *val = malloc(sizeof(u8));
>     ++      size_t val_len = 0;
>     ++      u8 data_type = 0;
>     +       int r;
>     +
>     +       r  = coolkey_get_attribute(card, obj, type, &val, &val_len,
>     &data_type);
>     +@@ -168,8 +168,8 @@ static int
>     + coolkey_get_attribute_boolean(sc_card_t *card,
>     sc_cardctl_coolkey_object_t *obj, CK_ATTRIBUTE_TYPE attr_type)
>     + {
>     +       int r;
>     +-      const u8 *val;
>     +-      size_t val_len;
>     ++      const u8 *val = malloc(sizeof(u8));
>     ++      size_t val_len = 0;
>     +
>     +       r = coolkey_get_attribute(card, obj, attr_type, &val,
>     &val_len, NULL);
>     +       if (r < 0) {
>     +@@ -186,7 +186,7 @@ static int
>     + coolkey_get_attribute_bytes(sc_card_t *card,
>     sc_cardctl_coolkey_object_t *obj, CK_ATTRIBUTE_TYPE type, u8 *data,
>     size_t *data_len, size_t max_data_len)
>     + {
>     +       const u8 *val;
>     +-      size_t val_len;
>     ++      size_t val_len = 0;
>     +       int r;
>     +
>     +       r = coolkey_get_attribute(card, obj, type, &val, &val_len,
>     NULL);
>     +Index: opensc-0.22.0/src/tools/opensc-explorer.c
>     +===================================================================
>     +--- opensc-0.22.0.orig/src/tools/opensc-explorer.c
>     ++++ opensc-0.22.0/src/tools/opensc-explorer.c
>     +@@ -2472,7 +2472,7 @@ int main(int argc, char *argv[])
>     +               char *line;
>     +               int cargc;
>     +               char *cargv[260];
>     +-              int multiple;
>     ++              int multiple = 0;
>     +               struct command *cmd;
>     +               char prompt[3*SC_MAX_PATH_STRING_SIZE];
>     +
>     diff --git

Ditto

>     a/package/opensc/0002-package-opensc-fix-strict-aliasing-warnings-as-errors.patch
>     b/package/opensc/0002-package-opensc-fix-strict-aliasing-warnings-as-errors.patch
>     new file mode 100644
>     index 0000000000..194f7c4305
>     --- /dev/null
>     +++
>     b/package/opensc/0002-package-opensc-fix-strict-aliasing-warnings-as-errors.patch
>     @@ -0,0 +1,140 @@
>     +
>     +package/opensc: fix strict aliasing warnings as errors

Ditto

>     +
>     +Building under sourcery-arm toolchain it is possible
>     +to find multiple of these warnings as errors, this patch
>     +will adress them
>     +
>     +Signed-off-by: José Pekkarinen <jose.pekkarinen@unikie.com
>     <mailto:jose.pekkarinen@unikie.com>>
>     +Index: opensc-0.22.0/src/libopensc/card-gids.c
>     +===================================================================
>     +--- opensc-0.22.0.orig/src/libopensc/card-gids.c
>     ++++ opensc-0.22.0/src/libopensc/card-gids.c
>     +@@ -691,7 +691,8 @@ static int gids_finish(sc_card_t *card)
>     + // the cmap file is used to detect the key algorithm / size
>     + static int gids_get_crypto_identifier_from_key_ref(sc_card_t
>     *card, const unsigned char keyref, unsigned char *cryptoidentifier) {
>     +       struct gids_private_data *data = (struct gids_private_data
>     *) card->drv_data;
>     +-      PCONTAINER_MAP_RECORD records = (PCONTAINER_MAP_RECORD)
>     data->cmapfile;
>     ++      PCONTAINER_MAP_RECORD records =
>     malloc(sizeof(CONTAINER_MAP_RECORD));
>     ++      memcpy(records, data->cmapfile, sizeof(CONTAINER_MAP_RECORD));
>     +       int recordsnum = (int) (data->cmapfilesize /
>     sizeof(CONTAINER_MAP_RECORD));
>     +       int index = keyref - GIDS_FIRST_KEY_IDENTIFIER;
>     +       if (index >= recordsnum) {
>     +@@ -1112,10 +1113,10 @@ gids_get_all_containers(sc_card_t* card,
>     + // return the detail about a container to emulate a pkcs15 card
>     + static int
>     + gids_get_container_detail(sc_card_t* card,
>     sc_cardctl_gids_get_container_t* container) {
>     +-      PCONTAINER_MAP_RECORD records = NULL;
>     ++      PCONTAINER_MAP_RECORD records =
>     malloc(sizeof(CONTAINER_MAP_RECORD));
>     +       struct gids_private_data *privatedata = (struct
>     gids_private_data *) card->drv_data;
>     +       size_t recordsnum, num, i;
>     +-      records = (PCONTAINER_MAP_RECORD) privatedata ->cmapfile;
>     ++      memcpy(records, privatedata->cmapfile,
>     sizeof(CONTAINER_MAP_RECORD));
>     +       recordsnum = (privatedata ->cmapfilesize /
>     sizeof(CONTAINER_MAP_RECORD));
>     +
>     +       num = container->containernum ;
>     +@@ -1158,7 +1159,8 @@ gids_get_container_detail(sc_card_t* car
>     + static int
>     + gids_select_key_reference(sc_card_t *card, sc_pkcs15_prkey_info_t*
>     key_info) {
>     +       struct gids_private_data *data = (struct gids_private_data
>     *) card->drv_data;
>     +-      PCONTAINER_MAP_RECORD records = (PCONTAINER_MAP_RECORD)
>     data->cmapfile;
>     ++      PCONTAINER_MAP_RECORD records =
>     malloc(sizeof(CONTAINER_MAP_RECORD));
>     ++      memcpy(records, data->cmapfile, sizeof(CONTAINER_MAP_RECORD));
>     +       size_t recordsnum;
>     +       int r;
>     +       char ch_tmp[10];
>     +@@ -1302,7 +1304,8 @@ static int gids_create_keyfile(sc_card_t
>     +       struct gids_private_data *data = (struct gids_private_data
>     *) card->drv_data;
>     +       size_t recordnum;
>     +       size_t containernum = key_info->key_reference -
>     GIDS_FIRST_KEY_IDENTIFIER;
>     +-      PCONTAINER_MAP_RECORD records = ((PCONTAINER_MAP_RECORD)
>     cmapbuffer) + containernum;
>     ++      PCONTAINER_MAP_RECORD records =
>     malloc(sizeof(CONTAINER_MAP_RECORD));
>     ++      memcpy(records, cmapbuffer + containernum,
>     sizeof(CONTAINER_MAP_RECORD));
>     +       struct gids_keymap_record* keymaprecord = NULL;
>     +       int i;
>     +
>     +@@ -1390,12 +1393,12 @@ static int gids_create_keyfile(sc_card_t
>     +
>     +       // convert char to wchar
>     +       for(i = 0; i < MAX_CONTAINER_NAME_LEN && object->label[i];
>     i++) {
>     +-              records->wszGuid[i] = object->label[i];
>     ++              records->wszGuid[i] = (unsigned short) object->label[i];
>     +       }
>     +
>     +       // TODO: check if a container with the same name already
>     exists and prevent is creation or change its name
>     +
>     +-      records->bFlags = CONTAINER_MAP_VALID_CONTAINER;
>     ++      records->bFlags = (unsigned char) CONTAINER_MAP_VALID_CONTAINER;
>     +       if (recordnum == 0) {
>     +               records->bFlags |= CONTAINER_MAP_DEFAULT_CONTAINER;
>     +       }
>     +@@ -1638,7 +1641,8 @@ static int gids_delete_container_num(sc_
>     +       size_t keymaprecordnum = 0;
>     +       struct gids_private_data *data = (struct gids_private_data
>     *) card->drv_data;
>     +       size_t recordnum;
>     +-      PCONTAINER_MAP_RECORD records = ((PCONTAINER_MAP_RECORD)
>     cmapbuffer) + containernum;
>     ++      PCONTAINER_MAP_RECORD records =
>     malloc(sizeof(CONTAINER_MAP_RECORD));
>     ++      memcpy(records, cmapbuffer + containernum,
>     sizeof(CONTAINER_MAP_RECORD));
>     +       struct gids_keymap_record* keymaprecord = NULL;
>     +
>     +       SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
>     +Index: opensc-0.22.0/src/libopensc/card-gpk.c
>     +===================================================================
>     +--- opensc-0.22.0.orig/src/libopensc/card-gpk.c
>     ++++ opensc-0.22.0/src/libopensc/card-gpk.c
>     +@@ -228,11 +228,12 @@ static int
>     + match_path(sc_card_t *card, unsigned short int **pathptr, size_t
>     *pathlen,
>     +               int need_info)
>     + {
>     +-      unsigned short int      *curptr, *ptr;
>     ++      u8                      *curptr;
>     ++      unsigned short int      *ptr;
>     +       size_t          curlen, len;
>     +       size_t          i;
>     +
>     +-      curptr = (unsigned short int *) card->cache.current_path.value;
>     ++      curptr = (u8 *) card->cache.current_path.value;
>     +       curlen = card->cache.current_path.len;
>     +       ptr    = *pathptr;
>     +       len    = *pathlen;
>     +@@ -242,7 +243,7 @@ match_path(sc_card_t *card, unsigned sho
>     +
>     +       /* Make sure path starts with MF.
>     +        * Note the cached path should always begin with MF. */
>     +-      if (ptr[0] != GPK_FID_MF || curptr[0] != GPK_FID_MF)
>     ++      if (ptr[0] != (GPK_FID_MF >> 8) || curptr[0] != (GPK_FID_MF
>      >> 8))
>     +               return 0;
>     +
>     +       for (i = 1; i < len && i < curlen; i++) {
>     +@@ -545,7 +546,7 @@ gpk_select_id(sc_card_t *card, int kind,
>     +       /* Fix up the path cache.
>     +        * NB we never cache the ID of an EF, just the DF path */
>     +       if (r == 0) {
>     +-              unsigned short int      *path;
>     ++              u8      *path;
>     +
>     +               switch (kind) {
>     +               case GPK_SEL_MF:
>     +@@ -555,7 +556,7 @@ gpk_select_id(sc_card_t *card, int kind,
>     +                       if (cp->len + 1 > SC_MAX_PATH_SIZE / 2) {
>     +                               return SC_ERROR_INTERNAL;
>     +                       }
>     +-                      path = (unsigned short int *) cp->value;
>     ++                      path = (u8 *) cp->value;
>     +                       path[cp->len++] = fid;
>     +               }
>     +       } else {
>     +Index: opensc-0.22.0/src/tools/gids-tool.c
>     +===================================================================
>     +--- opensc-0.22.0.orig/src/tools/gids-tool.c
>     ++++ opensc-0.22.0/src/tools/gids-tool.c
>     +@@ -401,7 +401,8 @@ static int print_info(sc_card_t *card) {
>     +               if (cmapfilesize == sizeof(cmapfile)) {
>     +                       printf("Unable to find the container file
>     (mscp\\cmapfile)\n");
>     +               } else {
>     +-                      PCONTAINER_MAP_RECORD cmaprecords =
>     (PCONTAINER_MAP_RECORD) cmapfile;
>     ++                      PCONTAINER_MAP_RECORD cmaprecords =
>     malloc(sizeof(CONTAINER_MAP_RECORD));
>     ++                      memcpy(cmaprecords, cmapfile,
>     sizeof(CONTAINER_MAP_RECORD));
>     +                       int cmaprecordnum = (cmapfilesize /
>     sizeof(CONTAINER_MAP_RECORD));
>     +                       int keymaprecordnum = -1;
>     +                       struct gids_keymap_record* keymaprecord =
>     ((struct gids_keymap_record*)(keymap +1));
>     diff --git a/package/opensc/Config.in b/package/opensc/Config.in
>     new file mode 100644
>     index 0000000000..d6b137a87f
>     --- /dev/null
>     +++ b/package/opensc/Config.in
>     @@ -0,0 +1,11 @@
>     +config BR2_PACKAGE_OPENSC
>     +       bool "opensc"
>     +       depends on !BR2_STATIC_LIBS # dlopen()
>     +       select BR2_PACKAGE_PCSC_LITE
>     +       select BR2_PACKAGE_OPENSSL
>     +       select BR2_PACKAGE_OPENSSL_FORCE_LIBOPENSSL
>     +       help
>     +         OpenSC provides a set of libraries and utilities to work
>     +         with smart cards.
>     +
>     + https://github.com/OpenSC/OpenSC/wiki
>     <https://github.com/OpenSC/OpenSC/wiki>
>     diff --git a/package/opensc/opensc.hash b/package/opensc/opensc.hash
>     new file mode 100644
>     index 0000000000..1e3472ba2a
>     --- /dev/null
>     +++ b/package/opensc/opensc.hash
>     @@ -0,0 +1,5 @@
>     +# From https://https://github.com/OpenSC/OpenSC/releases/
>     <https://github.com/OpenSC/OpenSC/releases/>

Here ^^^ you don't point the sha256 file

>     +sha256 
>     8d4e5347195ebea332be585df61dcc470331c26969e4b0447c851fb0844c7186 
>     opensc-0.22.0.tar.gz
>     +
>     +# Computed locally
>     +sha256 
>     376b54d4c5f4aa99421823fa4da93e3ab73096fce2400e89858632aa7da24a14 
>     COPYING
>     diff --git a/package/opensc/opensc.mk <http://opensc.mk>
>     b/package/opensc/opensc.mk <http://opensc.mk>
>     new file mode 100644
>     index 0000000000..7221eee944
>     --- /dev/null
>     +++ b/package/opensc/opensc.mk <http://opensc.mk>
>     @@ -0,0 +1,14 @@
>     +################################################################################
>     +#
>     +# opensc
>     +#
>     +################################################################################
>     +
>     +OPENSC_VERSION = 0.22.0
>     +OPENSC_SITE =
>     https://github.com/OpenSC/OpenSC/releases/download/$(OPENSC_VERSION)
>     <https://github.com/OpenSC/OpenSC/releases/download/$(OPENSC_VERSION)>
>     +OPENSC_LICENSE = LGPL-2.1+
>     +OPENSC_LICENSE_FILES = COPYING
>     +OPENSC_DEPENDENCIES = openssl pcsc-lite
>     +OPENSC_INSTALL_STAGING = YES
>     +
>     +$(eval $(autotools-package))
>     -- 
>     2.30.2
> 
> 
> 
> -- 
> 
>     José.
> 
> 
> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot
> 

I'm not sure I've catched everything, but the points above are a good 
starting point. Probably same goes for the other 2 patches in the series.

Best regards
José Pekkarinen Dec. 10, 2021, 11:02 a.m. UTC | #3
On Fri, Dec 10, 2021 at 12:29 PM Giulio Benetti <
giulio.benetti@benettiengineering.com> wrote:

> Hi José,
>
> please use plain-text,
>

Sorry, google thingy, not sure I can fix it :\



> On 10/12/21 07:20, José Pekkarinen wrote:
> >
> >     Hi,
> >
> >     Any comments in the following patchset?
> >
> >     Thanks!
> >
> >     José
> >
> >
> > On Fri, Dec 3, 2021 at 10:37 AM José Pekkarinen
>
> Only 1 week has passed, backlog is pretty big(478 patches at the moment)
>

Sorry, I was following linux kernel guidances

of the rule of 1w, I'll be more patient next time.


> > <jose.pekkarinen@unikie.com <mailto:jose.pekkarinen@unikie.com>> wrote:
> >
> >     The patch will add a basic opensc package to build
> >     on buildroot.
>
> This commit log is not sufficient. Can you please take a look at other
> commit log on while adding a "new package"? Try to imitate, that's a
> good starting point.
>

Most I see have empty comment. Mind to elaborate

what is missing?

>     Signed-off-by: José Pekkarinen <jose.pekkarinen@unikie.com
> >     <mailto:jose.pekkarinen@unikie.com>>
>
> This ^^^ SoB has a strange format, how did you produce the patch?
> Also how did you set the user.email in git?
>

It is properly set, so either git send-email or google added

that extra feaure.


Thanks!

José.
Giulio Benetti Dec. 10, 2021, 2:10 p.m. UTC | #4
Hi José,

> Il giorno 10 dic 2021, alle ore 12:03, José Pekkarinen <jose.pekkarinen@unikie.com> ha scritto:
> 
> 
> 
> 
>>> On Fri, Dec 10, 2021 at 12:29 PM Giulio Benetti <giulio.benetti@benettiengineering.com> wrote:
>>> Hi José,
>>> 
>>> please use plain-text,
>> 
>> Sorry, google thingy, not sure I can fix it :\

Use an e-mail client where you can set such setting. I’m on mobile now and maybe my answer will be a html. It happens sometimes.

>>  
>> On 10/12/21 07:20, José Pekkarinen wrote:
>> > 
>> >     Hi,
>> > 
>> >     Any comments in the following patchset?
>> > 
>> >     Thanks!
>> > 
>> >     José
>> > 
>> > 
>> > On Fri, Dec 3, 2021 at 10:37 AM José Pekkarinen 
>> 
>> Only 1 week has passed, backlog is pretty big(478 patches at the moment)
> 
> Sorry, I was following linux kernel guidances
> of the rule of 1w, I'll be more patient next time.

I honestly sent patches that stayed sitting there for even months in Linux ML. I don’t know this rule of the 1 week, but maybe I’m not aware.

>  
>> > <jose.pekkarinen@unikie.com <mailto:jose.pekkarinen@unikie.com>> wrote:
>> > 
>> >     The patch will add a basic opensc package to build
>> >     on buildroot.
>> 
>> This commit log is not sufficient. Can you please take a look at other 
>> commit log on while adding a "new package"? Try to imitate, that's a 
>> good starting point.
> 
> Most I see have empty comment. Mind to elaborate
> what is missing? 

Sorry, here the problem is how the commit log is written. Pick one of the latest new package adding and imitate it.

Usually the commit log is written with the infinite verbs. So something like:
“This patch adds opensc package”

and probably that’s enough.
You don’t need to specify “to build on Buildroot” because this patch will be applied to it so it’s implicit.

> 
>> >     Signed-off-by: José Pekkarinen <jose.pekkarinen@unikie.com
>> >     <mailto:jose.pekkarinen@unikie.com>>
>> 
>> This ^^^ SoB has a strange format, how did you produce the patch?
>> Also how did you set the user.email in git?
> 
> It is properly set, so either git send-email or google added
> that extra feaure.

I don’t think it’s google mail client, it seems like you’ve setup the user.e-mail wrong.
Try to check with:
# git config user.mail

Thanks for the Eddie anyway, I didn’t tell you on the previous email :-)

Best regards
Giulio

>  
> Thanks!
> 
> José.
> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot
José Pekkarinen Dec. 10, 2021, 2:18 p.m. UTC | #5
On Fri, Dec 10, 2021 at 4:10 PM Giulio Benetti
<giulio.benetti@benettiengineering.com> wrote:
>
> Hi José,
>
> Il giorno 10 dic 2021, alle ore 12:03, José Pekkarinen <jose.pekkarinen@unikie.com> ha scritto:
>
> 
>
>
> On Fri, Dec 10, 2021 at 12:29 PM Giulio Benetti <giulio.benetti@benettiengineering.com> wrote:
>>
>> Hi José,
>>
>> please use plain-text,
>
>
> Sorry, google thingy, not sure I can fix it :\
>
>
> Use an e-mail client where you can set such setting. I’m on mobile now and maybe my answer will be a html. It happens sometimes.
>
>
>>
>> On 10/12/21 07:20, José Pekkarinen wrote:
>> >
>> >     Hi,
>> >
>> >     Any comments in the following patchset?
>> >
>> >     Thanks!
>> >
>> >     José
>> >
>> >
>> > On Fri, Dec 3, 2021 at 10:37 AM José Pekkarinen
>>
>> Only 1 week has passed, backlog is pretty big(478 patches at the moment)
>
>
> Sorry, I was following linux kernel guidances
>
> of the rule of 1w, I'll be more patient next time.
>
>
> I honestly sent patches that stayed sitting there for even months in Linux ML. I don’t know this rule of the 1 week, but maybe I’m not aware.
>
>
>>
>> > <jose.pekkarinen@unikie.com <mailto:jose.pekkarinen@unikie.com>> wrote:
>> >
>> >     The patch will add a basic opensc package to build
>> >     on buildroot.
>>
>> This commit log is not sufficient. Can you please take a look at other
>> commit log on while adding a "new package"? Try to imitate, that's a
>> good starting point.
>
>
> Most I see have empty comment. Mind to elaborate
>
> what is missing?
>
>
> Sorry, here the problem is how the commit log is written. Pick one of the latest new package adding and imitate it.
>
> Usually the commit log is written with the infinite verbs. So something like:
> “This patch adds opensc package”
>
> and probably that’s enough.
> You don’t need to specify “to build on Buildroot” because this patch will be applied to it so it’s implicit.
>
>
>> >     Signed-off-by: José Pekkarinen <jose.pekkarinen@unikie.com
>> >     <mailto:jose.pekkarinen@unikie.com>>
>>
>> This ^^^ SoB has a strange format, how did you produce the patch?
>> Also how did you set the user.email in git?
>
>
> It is properly set, so either git send-email or google added
>
> that extra feaure.
>
>
> I don’t think it’s google mail client, it seems like you’ve setup the user.e-mail wrong.
> Try to check with:
> # git config user.mail

    Hi,

    I'm afraid it is google, see here:

$ git config user.email
jose.pekkarinen@unikie.com

    Looks fine.

    Best regards.

    José.
Giulio Benetti Dec. 10, 2021, 2:19 p.m. UTC | #6
> Il giorno 10 dic 2021, alle ore 15:10, Giulio Benetti <giulio.benetti@benettiengineering.com> ha scritto:
> 
> Hi José,
> 
>>> Il giorno 10 dic 2021, alle ore 12:03, José Pekkarinen <jose.pekkarinen@unikie.com> ha scritto:
>>> 
>> 
>> 
>> 
>>> On Fri, Dec 10, 2021 at 12:29 PM Giulio Benetti <giulio.benetti@benettiengineering.com> wrote:
>>> Hi José,
>>> 
>>> please use plain-text,
>> 
>> Sorry, google thingy, not sure I can fix it :\
> 
> Use an e-mail client where you can set such setting. I’m on mobile now and maybe my answer will be a html. It happens sometimes.
> 
>>  
>>> On 10/12/21 07:20, José Pekkarinen wrote:
>>> > 
>>> >     Hi,
>>> > 
>>> >     Any comments in the following patchset?
>>> > 
>>> >     Thanks!
>>> > 
>>> >     José
>>> > 
>>> > 
>>> > On Fri, Dec 3, 2021 at 10:37 AM José Pekkarinen 
>>> 
>>> Only 1 week has passed, backlog is pretty big(478 patches at the moment)
>> 
>> Sorry, I was following linux kernel guidances
>> of the rule of 1w, I'll be more patient next time.
> 
> I honestly sent patches that stayed sitting there for even months in Linux ML. I don’t know this rule of the 1 week, but maybe I’m not aware.
> 
>>  
>>> > <jose.pekkarinen@unikie.com <mailto:jose.pekkarinen@unikie.com>> wrote:
>>> > 
>>> >     The patch will add a basic opensc package to build
>>> >     on buildroot.
>>> 
>>> This commit log is not sufficient. Can you please take a look at other 
>>> commit log on while adding a "new package"? Try to imitate, that's a 
>>> good starting point.
>> 
>> Most I see have empty comment. Mind to elaborate
>> what is missing? 
> 
> Sorry, here the problem is how the commit log is written. Pick one of the latest new package adding and imitate it.
> 
> Usually the commit log is written with the infinite verbs. So something like:
> “This patch adds opensc package”
> 
> and probably that’s enough.
> You don’t need to specify “to build on Buildroot” because this patch will be applied to it so it’s implicit.
> 
>> 
>>> >     Signed-off-by: José Pekkarinen <jose.pekkarinen@unikie.com
>>> >     <mailto:jose.pekkarinen@unikie.com>>
>>> 
>>> This ^^^ SoB has a strange format, how did you produce the patch?
>>> Also how did you set the user.email in git?
>> 
>> It is properly set, so either git send-email or google added
>> that extra feaure.
> 
> I don’t think it’s google mail client, it seems like you’ve setup the user.e-mail wrong.
> Try to check with:
> # git config user.mail
> 
> Thanks for the Eddie anyway, I didn’t tell you on

s/Eddie/contribution


> the previous email :-)
> 
> Best regards
> Giulio
> 
>>  
>> Thanks!
>> 
>> José.
>> _______________________________________________
>> buildroot mailing list
>> buildroot@buildroot.org
>> https://lists.buildroot.org/mailman/listinfo/buildroot
diff mbox series

Patch

diff --git a/DEVELOPERS b/DEVELOPERS
index 70262eac8c..d92c38f07d 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -1455,6 +1455,7 @@  F:	support/testing/tests/package/test_zfs.py
 
 N:	José Pekkarinen <jose.pekkarinen@unikie.com>
 F:	package/softhsm2/
+F:	package/opensc/
 
 N:	Joseph Kogut <joseph.kogut@gmail.com>
 F:	package/at-spi2-atk/
diff --git a/package/Config.in b/package/Config.in
index e355ab1987..3cfcf372f3 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -1617,6 +1617,7 @@  menu "Hardware handling"
 	source "package/tslib/Config.in"
 	source "package/uhd/Config.in"
 	source "package/urg/Config.in"
+	source "package/opensc/Config.in"
 endmenu
 
 menu "Javascript"
diff --git a/package/opensc/0001-package-opensc-fix-maybe-uninitialized.patch b/package/opensc/0001-package-opensc-fix-maybe-uninitialized.patch
new file mode 100644
index 0000000000..1f6a2e6f42
--- /dev/null
+++ b/package/opensc/0001-package-opensc-fix-maybe-uninitialized.patch
@@ -0,0 +1,69 @@ 
+package:opensc: Fix maybe uninitialized issues
+
+This patch will fix some warning treated as errors
+that highlight maybe uninitialized variables.
+
+Signed-off-by: José Pekkarinen <jose.pekkarinen@unikie.com>
+Index: opensc-0.22.0/src/pkcs15init/pkcs15-asepcos.c
+===================================================================
+--- opensc-0.22.0.orig/src/pkcs15init/pkcs15-asepcos.c
++++ opensc-0.22.0/src/pkcs15init/pkcs15-asepcos.c
+@@ -221,7 +221,7 @@ static int asepcos_do_store_pin(sc_profi
+ {
+ 	sc_file_t *nfile = NULL;
+ 	u8  buf[64], sbuf[64], *p = buf, *q = sbuf;
+-	int r, akn;
++	int r, akn = 0;
+ 
+ 	if (auth_info->auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN)
+ 		return SC_ERROR_OBJECT_NOT_VALID;
+Index: opensc-0.22.0/src/libopensc/pkcs15-coolkey.c
+===================================================================
+--- opensc-0.22.0.orig/src/libopensc/pkcs15-coolkey.c
++++ opensc-0.22.0/src/libopensc/pkcs15-coolkey.c
+@@ -147,9 +147,9 @@ coolkey_find_matching_cert(sc_card_t *ca
+ static int
+ coolkey_get_attribute_ulong(sc_card_t *card, sc_cardctl_coolkey_object_t *obj, CK_ATTRIBUTE_TYPE type, CK_ULONG *value)
+ {
+-	const u8 *val;
+-	size_t val_len;
+-	u8 data_type;
++	const u8 *val = malloc(sizeof(u8));
++	size_t val_len = 0;
++	u8 data_type = 0;
+ 	int r;
+ 
+ 	r  = coolkey_get_attribute(card, obj, type, &val, &val_len, &data_type);
+@@ -168,8 +168,8 @@ static int
+ coolkey_get_attribute_boolean(sc_card_t *card, sc_cardctl_coolkey_object_t *obj, CK_ATTRIBUTE_TYPE attr_type)
+ {
+ 	int r;
+-	const u8 *val;
+-	size_t val_len;
++	const u8 *val = malloc(sizeof(u8));
++	size_t val_len = 0;
+ 
+ 	r = coolkey_get_attribute(card, obj, attr_type, &val, &val_len, NULL);
+ 	if (r < 0) {
+@@ -186,7 +186,7 @@ static int
+ coolkey_get_attribute_bytes(sc_card_t *card, sc_cardctl_coolkey_object_t *obj, CK_ATTRIBUTE_TYPE type, u8 *data, size_t *data_len, size_t max_data_len)
+ {
+ 	const u8 *val;
+-	size_t val_len;
++	size_t val_len = 0;
+ 	int r;
+ 
+ 	r = coolkey_get_attribute(card, obj, type, &val, &val_len, NULL);
+Index: opensc-0.22.0/src/tools/opensc-explorer.c
+===================================================================
+--- opensc-0.22.0.orig/src/tools/opensc-explorer.c
++++ opensc-0.22.0/src/tools/opensc-explorer.c
+@@ -2472,7 +2472,7 @@ int main(int argc, char *argv[])
+ 		char *line;
+ 		int cargc;
+ 		char *cargv[260];
+-		int multiple;
++		int multiple = 0;
+ 		struct command *cmd;
+ 		char prompt[3*SC_MAX_PATH_STRING_SIZE];
+ 
diff --git a/package/opensc/0002-package-opensc-fix-strict-aliasing-warnings-as-errors.patch b/package/opensc/0002-package-opensc-fix-strict-aliasing-warnings-as-errors.patch
new file mode 100644
index 0000000000..194f7c4305
--- /dev/null
+++ b/package/opensc/0002-package-opensc-fix-strict-aliasing-warnings-as-errors.patch
@@ -0,0 +1,140 @@ 
+
+package/opensc: fix strict aliasing warnings as errors
+
+Building under sourcery-arm toolchain it is possible
+to find multiple of these warnings as errors, this patch
+will adress them
+
+Signed-off-by: José Pekkarinen <jose.pekkarinen@unikie.com>
+Index: opensc-0.22.0/src/libopensc/card-gids.c
+===================================================================
+--- opensc-0.22.0.orig/src/libopensc/card-gids.c
++++ opensc-0.22.0/src/libopensc/card-gids.c
+@@ -691,7 +691,8 @@ static int gids_finish(sc_card_t *card)
+ // the cmap file is used to detect the key algorithm / size
+ static int gids_get_crypto_identifier_from_key_ref(sc_card_t *card, const unsigned char keyref, unsigned char *cryptoidentifier) {
+ 	struct gids_private_data *data = (struct gids_private_data *) card->drv_data;
+-	PCONTAINER_MAP_RECORD records = (PCONTAINER_MAP_RECORD) data->cmapfile;
++	PCONTAINER_MAP_RECORD records = malloc(sizeof(CONTAINER_MAP_RECORD));
++	memcpy(records, data->cmapfile, sizeof(CONTAINER_MAP_RECORD));
+ 	int recordsnum = (int) (data->cmapfilesize / sizeof(CONTAINER_MAP_RECORD));
+ 	int index = keyref - GIDS_FIRST_KEY_IDENTIFIER;
+ 	if (index >= recordsnum) {
+@@ -1112,10 +1113,10 @@ gids_get_all_containers(sc_card_t* card,
+ // return the detail about a container to emulate a pkcs15 card
+ static int
+ gids_get_container_detail(sc_card_t* card, sc_cardctl_gids_get_container_t* container) {
+-	PCONTAINER_MAP_RECORD records = NULL;
++	PCONTAINER_MAP_RECORD records = malloc(sizeof(CONTAINER_MAP_RECORD));
+ 	struct gids_private_data *privatedata = (struct gids_private_data *) card->drv_data;
+ 	size_t recordsnum, num, i;
+-	records = (PCONTAINER_MAP_RECORD) privatedata ->cmapfile;
++	memcpy(records, privatedata->cmapfile, sizeof(CONTAINER_MAP_RECORD));
+ 	recordsnum = (privatedata ->cmapfilesize / sizeof(CONTAINER_MAP_RECORD));
+ 
+ 	num = container->containernum ;
+@@ -1158,7 +1159,8 @@ gids_get_container_detail(sc_card_t* car
+ static int
+ gids_select_key_reference(sc_card_t *card, sc_pkcs15_prkey_info_t* key_info) {
+ 	struct gids_private_data *data = (struct gids_private_data *) card->drv_data;
+-	PCONTAINER_MAP_RECORD records = (PCONTAINER_MAP_RECORD) data->cmapfile;
++	PCONTAINER_MAP_RECORD records = malloc(sizeof(CONTAINER_MAP_RECORD));
++	memcpy(records, data->cmapfile, sizeof(CONTAINER_MAP_RECORD));
+ 	size_t recordsnum;
+ 	int r;
+ 	char ch_tmp[10];
+@@ -1302,7 +1304,8 @@ static int gids_create_keyfile(sc_card_t
+ 	struct gids_private_data *data = (struct gids_private_data *) card->drv_data;
+ 	size_t recordnum;
+ 	size_t containernum = key_info->key_reference - GIDS_FIRST_KEY_IDENTIFIER;
+-	PCONTAINER_MAP_RECORD records = ((PCONTAINER_MAP_RECORD) cmapbuffer) + containernum;
++	PCONTAINER_MAP_RECORD records = malloc(sizeof(CONTAINER_MAP_RECORD));
++	memcpy(records, cmapbuffer + containernum, sizeof(CONTAINER_MAP_RECORD));
+ 	struct gids_keymap_record* keymaprecord = NULL;
+ 	int i;
+ 
+@@ -1390,12 +1393,12 @@ static int gids_create_keyfile(sc_card_t
+ 
+ 	// convert char to wchar
+ 	for(i = 0; i < MAX_CONTAINER_NAME_LEN && object->label[i]; i++) {
+-		records->wszGuid[i] = object->label[i];
++		records->wszGuid[i] = (unsigned short) object->label[i];
+ 	}
+ 
+ 	// TODO: check if a container with the same name already exists and prevent is creation or change its name
+ 
+-	records->bFlags = CONTAINER_MAP_VALID_CONTAINER;
++	records->bFlags = (unsigned char) CONTAINER_MAP_VALID_CONTAINER;
+ 	if (recordnum == 0) {
+ 		records->bFlags |= CONTAINER_MAP_DEFAULT_CONTAINER;
+ 	}
+@@ -1638,7 +1641,8 @@ static int gids_delete_container_num(sc_
+ 	size_t keymaprecordnum = 0;
+ 	struct gids_private_data *data = (struct gids_private_data *) card->drv_data;
+ 	size_t recordnum;
+-	PCONTAINER_MAP_RECORD records = ((PCONTAINER_MAP_RECORD) cmapbuffer) + containernum;
++	PCONTAINER_MAP_RECORD records = malloc(sizeof(CONTAINER_MAP_RECORD));
++	memcpy(records, cmapbuffer + containernum, sizeof(CONTAINER_MAP_RECORD));
+ 	struct gids_keymap_record* keymaprecord = NULL;
+ 
+ 	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
+Index: opensc-0.22.0/src/libopensc/card-gpk.c
+===================================================================
+--- opensc-0.22.0.orig/src/libopensc/card-gpk.c
++++ opensc-0.22.0/src/libopensc/card-gpk.c
+@@ -228,11 +228,12 @@ static int
+ match_path(sc_card_t *card, unsigned short int **pathptr, size_t *pathlen,
+ 		int need_info)
+ {
+-	unsigned short int	*curptr, *ptr;
++	u8			*curptr;
++	unsigned short int	*ptr;
+ 	size_t		curlen, len;
+ 	size_t		i;
+ 
+-	curptr = (unsigned short int *) card->cache.current_path.value;
++	curptr = (u8 *) card->cache.current_path.value;
+ 	curlen = card->cache.current_path.len;
+ 	ptr    = *pathptr;
+ 	len    = *pathlen;
+@@ -242,7 +243,7 @@ match_path(sc_card_t *card, unsigned sho
+ 
+ 	/* Make sure path starts with MF.
+ 	 * Note the cached path should always begin with MF. */
+-	if (ptr[0] != GPK_FID_MF || curptr[0] != GPK_FID_MF)
++	if (ptr[0] != (GPK_FID_MF >> 8) || curptr[0] != (GPK_FID_MF >> 8))
+ 		return 0;
+ 
+ 	for (i = 1; i < len && i < curlen; i++) {
+@@ -545,7 +546,7 @@ gpk_select_id(sc_card_t *card, int kind,
+ 	/* Fix up the path cache.
+ 	 * NB we never cache the ID of an EF, just the DF path */
+ 	if (r == 0) {
+-		unsigned short int	*path;
++		u8	*path;
+ 
+ 		switch (kind) {
+ 		case GPK_SEL_MF:
+@@ -555,7 +556,7 @@ gpk_select_id(sc_card_t *card, int kind,
+ 			if (cp->len + 1 > SC_MAX_PATH_SIZE / 2) {
+ 				return SC_ERROR_INTERNAL;
+ 			}
+-			path = (unsigned short int *) cp->value;
++			path = (u8 *) cp->value;
+ 			path[cp->len++] = fid;
+ 		}
+ 	} else {
+Index: opensc-0.22.0/src/tools/gids-tool.c
+===================================================================
+--- opensc-0.22.0.orig/src/tools/gids-tool.c
++++ opensc-0.22.0/src/tools/gids-tool.c
+@@ -401,7 +401,8 @@ static int print_info(sc_card_t *card) {
+ 		if (cmapfilesize == sizeof(cmapfile)) {
+ 			printf("Unable to find the container file (mscp\\cmapfile)\n");
+ 		} else {
+-			PCONTAINER_MAP_RECORD cmaprecords = (PCONTAINER_MAP_RECORD) cmapfile;
++			PCONTAINER_MAP_RECORD cmaprecords = malloc(sizeof(CONTAINER_MAP_RECORD));
++			memcpy(cmaprecords, cmapfile, sizeof(CONTAINER_MAP_RECORD));
+ 			int cmaprecordnum = (cmapfilesize / sizeof(CONTAINER_MAP_RECORD));
+ 			int keymaprecordnum = -1;
+ 			struct gids_keymap_record* keymaprecord = ((struct gids_keymap_record*)(keymap +1));
diff --git a/package/opensc/Config.in b/package/opensc/Config.in
new file mode 100644
index 0000000000..d6b137a87f
--- /dev/null
+++ b/package/opensc/Config.in
@@ -0,0 +1,11 @@ 
+config BR2_PACKAGE_OPENSC
+	bool "opensc"
+	depends on !BR2_STATIC_LIBS # dlopen()
+	select BR2_PACKAGE_PCSC_LITE
+	select BR2_PACKAGE_OPENSSL
+	select BR2_PACKAGE_OPENSSL_FORCE_LIBOPENSSL
+	help
+	  OpenSC provides a set of libraries and utilities to work
+	  with smart cards.
+
+	  https://github.com/OpenSC/OpenSC/wiki
diff --git a/package/opensc/opensc.hash b/package/opensc/opensc.hash
new file mode 100644
index 0000000000..1e3472ba2a
--- /dev/null
+++ b/package/opensc/opensc.hash
@@ -0,0 +1,5 @@ 
+# From https://https://github.com/OpenSC/OpenSC/releases/
+sha256  8d4e5347195ebea332be585df61dcc470331c26969e4b0447c851fb0844c7186  opensc-0.22.0.tar.gz
+
+# Computed locally
+sha256  376b54d4c5f4aa99421823fa4da93e3ab73096fce2400e89858632aa7da24a14  COPYING
diff --git a/package/opensc/opensc.mk b/package/opensc/opensc.mk
new file mode 100644
index 0000000000..7221eee944
--- /dev/null
+++ b/package/opensc/opensc.mk
@@ -0,0 +1,14 @@ 
+################################################################################
+#
+# opensc
+#
+################################################################################
+
+OPENSC_VERSION = 0.22.0
+OPENSC_SITE = https://github.com/OpenSC/OpenSC/releases/download/$(OPENSC_VERSION)
+OPENSC_LICENSE = LGPL-2.1+
+OPENSC_LICENSE_FILES = COPYING
+OPENSC_DEPENDENCIES = openssl pcsc-lite
+OPENSC_INSTALL_STAGING = YES
+
+$(eval $(autotools-package))