Skip to content

periph/spi: undefined behavior for length > MAX_INT #1769

@LudwigKnuepfer

Description

@LudwigKnuepfer

The documentation for spi_transfer_regs (and others) does not specify what happens if the length parameter exceeds the maximum value the return type can take.

For reference:

/**
 * @brief Transfer a number of bytes from/to a given register address
 *
 * This function is a shortcut function for easier handling of register based SPI devices. As
 * many SPI devices use a register based addressing scheme, this function is a convenient short-
 * cut for interfacing with such devices.
 *
 * @param[in] dev       SPI device to use
 * @param[in] reg       Register address to transfer data to/from
 * @param[in] out       Byte array to send data from, set NULL if only receiving
 * @param[out] in       Byte buffer to read into, set NULL if only sending
 * @param[in] length    Number of bytes to transfer
 *
 * @return              Number of bytes that were transfered
 * @return              -1 on error
 */
int spi_transfer_regs(spi_t dev, uint8_t reg, char *out, char *in, unsigned int length);

I did not check whether this type of documentation error exists for other periph interfaces as well. It should be done.

Metadata

Metadata

Assignees

Labels

Area: docArea: DocumentationType: bugThe issue reports a bug / The PR fixes a bug (including spelling errors)

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions