A safer memcpy with very limited use cases

subetha d8cBOw

Sub-Etha SoftwareHere is a quick one… At my day job, I found lines of code like this: memcpy(systemDataPtr- >serialNumber, resp.serialNumber, 16); A quick peek at systemDataPtr- >serialNumber shows it defined as this: unsigned char serialNumber[MAX_SERIAL_NUMBER_LENGTH]; …with that constant defined as: #define MAX_SERIAL_NUMBER_LENGTH 16 So while 16 is correct, the use of hard-coded “magic …

Read More

From: Retro Roundup