X-Git-Url: http://developer.intra2net.com/git/?p=libftdi;a=blobdiff_plain;f=src%2Fftdi.c;h=6de60bee189ad902ad59753a3f91124cf0e12507;hp=fc561b5a6cd4c4363de0f2a5c4954d2df90ff2dd;hb=200bd3ed2e1d2389217be44c0adc728909a2a100;hpb=213fb57e9e2ce7e047d753bea68369d524760c0c diff --git a/src/ftdi.c b/src/ftdi.c index fc561b5..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 ***************************************************************************/ @@ -3114,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 @@ -3252,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; }