From 843aa92266e3df22160d16a30aa4d731fccb9ec5 Mon Sep 17 00:00:00 2001 From: Eric Curtin Date: Mon, 8 May 2023 16:42:21 +0100 Subject: [PATCH] Change hdr_offset to signed value, so lseek64 return can be checked The lines: if (instance == PRIMARY_GPT) hdr_offset = block_size; else { hdr_offset = lseek64(fd, 0, SEEK_END) - block_size; } if (hdr_offset < 0) { fprintf(stderr, "%s: Failed to get gpt header offset\n", __func__); goto error; } are error checked. But previously hdr_offset could never be less than zero because it was unsigned. --- gpt-utils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gpt-utils.cpp b/gpt-utils.cpp index b913d42..8405f1e 100644 --- a/gpt-utils.cpp +++ b/gpt-utils.cpp @@ -442,7 +442,7 @@ static uint8_t *gpt_get_header(const char *partname, enum gpt_instance instance) { uint8_t *hdr = NULL; char devpath[PATH_MAX] = { 0 }; - uint64_t hdr_offset = 0; + off_t hdr_offset = 0; uint32_t block_size = 0; int fd = -1; if (!partname) {