Skip to content

Comments

Some C99 and security/range checking cleanup, plus a new example program#45

Open
michaelrsweet wants to merge 7 commits intoricmoo:masterfrom
michaelrsweet:master
Open

Some C99 and security/range checking cleanup, plus a new example program#45
michaelrsweet wants to merge 7 commits intoricmoo:masterfrom
michaelrsweet:master

Conversation

@michaelrsweet
Copy link

Hi,

I found your "library" and wanted to contribute a few little changes:

  • Updated the header to use stdbool.h instead of defining its own bool type and constants.
  • Added VERSION_MIN, VERSION_MAX, and VERSION_AUTO defines.
  • Updated qrcode_initData to range check the ecc and version fields and implemented automatic versioning and length range checking.
  • Updated qrcode_initText to range check the text string length before passing it to qrcode_initData, since size_t is usually 64-bits and the length is only 16...
  • Added an example/test program that generates a SVG file of the QR code.

- The bool type is C99 and defined in stdbool.h.  Use it instead of defining
  a new bool type and constants.
- Add VERSION_MIN and VERSION_MAX defines along with a VERSION_AUTO (0) that
  has qrcode_initXxx calculate the optimal size.
- Range check the data length to the version used.
- Range check the ecc and version arguments.
- Range check the text length instead of passing a 64-bit string length to a
  uint16_t argument.
- In qrcode_getModule, use a right shift from 128 instead of a left shift to
  avoid the extra arithmetic.
- Trim trailing whitespace from lines (this is something my editor did by
  default).
@michaelrsweet
Copy link
Author

Oh, and apologies for the number of whitespace changes on the blank lines - my editor strips trailing whitespace so there are a lot of changes there that are just whitespace getting deleted... :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant