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.
merge-requests/7/head
Eric Curtin 2 years ago committed by Caleb Connolly
parent e705c38010
commit 843aa92266
No known key found for this signature in database
GPG Key ID: 0583312B195F64B6
  1. 2
      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) {

Loading…
Cancel
Save