summaryrefslogtreecommitdiff
path: root/lib/ipmi_hpmfwupg.c
diff options
context:
space:
mode:
authorZdenek Styblik <stybla@turnovfree.net>2016-06-09 11:48:29 +0200
committerZdenek Styblik <stybla@turnovfree.net>2016-06-09 12:01:48 +0200
commit9341982a381ac4b0785e3fefe4b334f1c91f9385 (patch)
tree502ae5cae6b2cdce26550b0481ae6191d4287453 /lib/ipmi_hpmfwupg.c
parent4ecac48c68c1f4d5a3f54c36f22fe74b41419c34 (diff)
downloadipmitool-9341982a381ac4b0785e3fefe4b334f1c91f9385.tar.gz
ID:335 - Check return value of fseek(), prevent segfault
Commit adds a check as a workaround for segfault reported in ID:335. However, the proper fix is to rewrite parts of lib/ipmi_hpmfwupg.c not to put whole firmware image into memory. Also, MD5 checksum part needs to be rewritten, because it won't work for large firmware images.
Diffstat (limited to 'lib/ipmi_hpmfwupg.c')
-rw-r--r--lib/ipmi_hpmfwupg.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/ipmi_hpmfwupg.c b/lib/ipmi_hpmfwupg.c
index 9cbd4ff..bbcffc0 100644
--- a/lib/ipmi_hpmfwupg.c
+++ b/lib/ipmi_hpmfwupg.c
@@ -1399,7 +1399,12 @@ HpmfwupgGetBufferFromFile(char *imageFilename,
return HPMFWUPG_ERROR;
}
/* Get the raw data in file */
- fseek(pImageFile, 0, SEEK_END);
+ ret = fseek(pImageFile, 0, SEEK_END);
+ if (ret != 0) {
+ lprintf(LOG_ERR, "Failed to seek in the image file '%s'",
+ imageFilename);
+ return HPMFWUPG_ERROR;
+ }
pFwupgCtx->imageSize = ftell(pImageFile);
pFwupgCtx->pImageData = malloc(sizeof(unsigned char)*pFwupgCtx->imageSize);
if (pFwupgCtx->pImageData == NULL) {