Giter VIP home page Giter VIP logo

Comments (4)

keldonin avatar keldonin commented on May 27, 2024

Hi @JSchy65 , thank you for using the pkcs11 tools, and for reporting an issue along with comprehensive information. I've never been hit by optimization issues so far, so that's an interesting one.

I would need to reproduce the issue. Can you give me more information about the PKCS#11 library you are using? Also, (out of curiosity), why is your token label longer than the limit imposed by CK_TOKEN_INFO?

For the resolution, I would like to find a way that doesn't add compiler-specific syntax, as this code currently compiles on other compilers than LLVM or GCC, and might not like the attribute() directive. Could the issue be caused by the ternary operator ? Have you tried changing rtrim() to use a simple if() {} else {} directive instead?

from pkcs11-tools.

keldonin avatar keldonin commented on May 27, 2024

Hi @JSchy65 , the way how the comparison was made had several shortcomings, one of them being that it modified the CK_TOKEN_INFO structure, possibly making it unusable for further use.

I have rewritten that section completely:

  • trailing spaces at the end of CK_TOKEN_INFO.label are stripped
  • if the token label to compare is longer than what allows CK_TOKEN_INFO.label, a warning is printed and the comparison fails
  • In the end, both strings are compared, but limited to the max capacity of CK_TOKEN_INFO.label.

I tested with several token label sizes, including labels filling entirely the label array, and these seemed to work.

Before I merge this back to the master branch, I would appreciate if you could try it out and confirm it fixes your specific issue. Just checkout branch fix_issue_7, commit 34aa8ae.

Thanks!

from pkcs11-tools.

JSchy65 avatar JSchy65 commented on May 27, 2024

Hi Eric,
I have tested your fix now and yes I confirm that it fixes the issue I have reported above. I tested with labels of various sizes (1, 10, 31, 32, 33) and also with the gcc compiler with various optimisation leves (-O0, -O1, -O2, -O3). In each case the fix behaved as expected -> Ok from my side :-)

I like the way very much that you have replaced that original implementation of the rtrim() with the new tokenlabelcmp(). In my opinion that makes the source easier to understand and is a more clear approach.

Thank you very much.

from pkcs11-tools.

keldonin avatar keldonin commented on May 27, 2024

Issue solved, will be published in v1.0.3 release.

from pkcs11-tools.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.