diff options
author | Tomasz Kramkowski <tk@the-tk.com> | 2016-11-23 22:22:46 +0000 |
---|---|---|
committer | Tomasz Kramkowski <tk@the-tk.com> | 2016-11-23 22:22:46 +0000 |
commit | 4b56f68e9876be3c42b93be1600cfe6d96ca1530 (patch) | |
tree | 638aa51a435dd6a40a555694c84c78a8f0b72fc0 | |
parent | 81ba1f28a675cd0e7fda82cb87e0ae6f1e797aab (diff) | |
download | hktool-4b56f68e9876be3c42b93be1600cfe6d96ca1530.tar.gz hktool-4b56f68e9876be3c42b93be1600cfe6d96ca1530.tar.xz hktool-4b56f68e9876be3c42b93be1600cfe6d96ca1530.zip |
halfkay.c: Prevent shift past type size
-rw-r--r-- | halfkay.c | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -89,10 +89,11 @@ static void usbsendcmd(void *data, size_t size, bool firstxfer) static void fmtcmd(void *_dest, const struct flashparams *fp, size_t addr) { + static const size_t MAX_SHIFT = sizeof addr * CHAR_BIT / 8; unsigned char *dest = _dest; addr >>= fp->addrshft; - for (size_t i = 0; i < fp->cmdsz; i++) + for (size_t i = 0; i < fp->cmdsz && i < MAX_SHIFT; i++) dest[i] = (addr >> (i * 8)) & 0xFF; } |