pez-globo / pufferfish-software

All software for the Pufferfish ventilator.
Apache License 2.0
0 stars 1 forks source link

Driver/I2C: switch to read_ntoh instead of parse_network_order #302

Closed rohanpurohit closed 3 years ago

rohanpurohit commented 3 years ago

This PR proposes switching to read_ntoh instead of parse_network_order: since the implementation of parse_network_order could have lead to a buffer overflow if the correct size wasn't passed

rohanpurohit commented 3 years ago

@ethanjli This PR is ready for review.

rohanpurohit commented 3 years ago
  1. This project is licensed under Apache License v2.0 for any software, and Solderpad Hardware License v2.1 for any hardware - do you agree that your contributions to this project will be under these licenses, too? Yes.
  2. Were any of these contributions also part of work you did for an employer or a client? No.
  3. Does this work include, or is it based on, any third-party work which you did not create? No.
ethanjli commented 3 years ago

As discussed in our meeting: the naming of read_ntoh is kind of confusing. The naming will be clearer (and consistent with how Python structs require us to specify whether a field is bigend or littleend rather than network order or host order) if we do something like:

read_bigend(const uint8_t *big_endian, uint16_t &result):
    result = set_byte<0, uint16_t>(network_endian[1]) + set_byte<1, uint16_t>(network_endian[0])