X-Git-Url: http://developer.intra2net.com/git/?p=libftdi;a=blobdiff_plain;f=src%2Fftdi.c;h=6de60bee189ad902ad59753a3f91124cf0e12507;hp=adf682f561172f0f44318cd5b41a2ec8ecbaa3b0;hb=200bd3ed2e1d2389217be44c0adc728909a2a100;hpb=5e77e87002972d3e5794a4b375cd78a5ae6dde01 diff --git a/src/ftdi.c b/src/ftdi.c index adf682f..6de60be 100644 --- a/src/ftdi.c +++ b/src/ftdi.c @@ -2,7 +2,7 @@ ftdi.c - description ------------------- begin : Fri Apr 4 2003 - copyright : (C) 2003-2010 by Intra2net AG + copyright : (C) 2003-2011 by Intra2net AG and the libftdi developers email : opensource@intra2net.com ***************************************************************************/ @@ -2944,7 +2944,6 @@ int ftdi_eeprom_decode(struct ftdi_context *ftdi, int verbose) "IOMODE","BB_WR","BB_RD" }; char *cbus_BB[] = {"RXF","TXE","RD", "WR"}; - int i; if (eeprom->invert) { @@ -3115,7 +3114,7 @@ int ftdi_get_eeprom_value(struct ftdi_context *ftdi, enum ftdi_eeprom_value valu No parameter checking is performed \param ftdi pointer to ftdi_context - \param value_name Enum of the value to query + \param value_name Enum of the value to set \param value to set \retval 0: all fine @@ -3253,12 +3252,22 @@ int ftdi_set_eeprom_value(struct ftdi_context *ftdi, enum ftdi_eeprom_value valu \retval 0: All fine \retval -1: struct ftdi_contxt or ftdi_eeprom missing + \retval -2: Not enough room to store eeprom */ int ftdi_get_eeprom_buf(struct ftdi_context *ftdi, unsigned char * buf, int size) { if (!ftdi || !(ftdi->eeprom)) ftdi_error_return(-1, "No appropriate structure"); + + if (!buf || size < ftdi->eeprom->size) + ftdi_error_return(-1, "Not enough room to store eeprom"); + + // Only copy up to FTDI_MAX_EEPROM_SIZE bytes + if (size > FTDI_MAX_EEPROM_SIZE) + size = FTDI_MAX_EEPROM_SIZE; + memcpy(buf, ftdi->eeprom->buf, size); + return 0; }