0001-src-p11_attr.c-fix-build-with-gcc-4.8.patch 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. From ba44b87318ed89e489fa3ce0a5d66002afa2bd6c Mon Sep 17 00:00:00 2001
  2. From: Fabrice Fontaine <fontaine.fabrice@gmail.com>
  3. Date: Fri, 12 Aug 2022 11:54:54 +0200
  4. Subject: [PATCH] src/p11_attr.c: fix build with gcc 4.8
  5. Fix the following build failure with gcc 4.8 raised since version 0.4.12
  6. and
  7. https://github.com/OpenSC/libp11/commit/639a4b6463278c0119a2ec60b261da3e5330fb33:
  8. p11_attr.c: In function 'pkcs11_zap_attrs':
  9. p11_attr.c:167:2: error: 'for' loop initial declarations are only allowed in C99 mode
  10. for (unsigned i = 0; i < 32; i++) {
  11. ^
  12. p11_attr.c:167:2: note: use option -std=c99 or -std=gnu99 to compile your code
  13. Fixes:
  14. - http://autobuild.buildroot.org/results/4391020fb5738cc8c26dc53783a6228bbf76473a
  15. Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
  16. [Retrieved from:
  17. https://github.com/OpenSC/libp11/commit/ba44b87318ed89e489fa3ce0a5d66002afa2bd6c]
  18. ---
  19. src/p11_attr.c | 4 +++-
  20. 1 file changed, 3 insertions(+), 1 deletion(-)
  21. diff --git a/src/p11_attr.c b/src/p11_attr.c
  22. index d49456ff..d425241a 100644
  23. --- a/src/p11_attr.c
  24. +++ b/src/p11_attr.c
  25. @@ -162,9 +162,11 @@ void pkcs11_addattr_obj(PKCS11_TEMPLATE *tmpl, int type, pkcs11_i2d_fn enc, void
  26. void pkcs11_zap_attrs(PKCS11_TEMPLATE *tmpl)
  27. {
  28. + unsigned int i;
  29. +
  30. if (!tmpl->allocated)
  31. return;
  32. - for (unsigned i = 0; i < 32; i++) {
  33. + for (i = 0; i < 32; i++) {
  34. if (tmpl->allocated & (1<<i))
  35. OPENSSL_free(tmpl->attrs[i].pValue);
  36. }