Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/kern_ctf.c
Show First 20 Lines • Show All 238 Lines • ▼ Show 20 Lines | #endif | ||||
*/ | */ | ||||
if ((error = vn_rdwr(UIO_READ, nd.ni_vp, raw == NULL ? ctftab : raw, | if ((error = vn_rdwr(UIO_READ, nd.ni_vp, raw == NULL ? ctftab : raw, | ||||
shdr[i].sh_size, shdr[i].sh_offset, UIO_SYSSPACE, IO_NODELOCKED, | shdr[i].sh_size, shdr[i].sh_offset, UIO_SYSSPACE, IO_NODELOCKED, | ||||
td->td_ucred, NOCRED, NULL, td)) != 0) | td->td_ucred, NOCRED, NULL, td)) != 0) | ||||
goto out; | goto out; | ||||
/* Check if decompression is required. */ | /* Check if decompression is required. */ | ||||
if (raw != NULL) { | if (raw != NULL) { | ||||
z_stream zs; | uLongf destlen; | ||||
markj: FreeBSD style discourages CamelCase. The variable should be called something like `destlen`… | |||||
int ret; | int ret; | ||||
/* | /* | ||||
* The header isn't compressed, so copy that into the | * The header isn't compressed, so copy that into the | ||||
* CTF buffer first. | * CTF buffer first. | ||||
*/ | */ | ||||
bcopy(ctf_hdr, ctftab, sizeof(ctf_hdr)); | bcopy(ctf_hdr, ctftab, sizeof(ctf_hdr)); | ||||
/* Initialise the zlib structure. */ | destlen = sz - sizeof(ctf_hdr); | ||||
bzero(&zs, sizeof(zs)); | ret = uncompress(((uint8_t *) ctftab) + sizeof(ctf_hdr), | ||||
&destlen, ((uint8_t *) raw) + sizeof(ctf_hdr), | |||||
if (inflateInit(&zs) != Z_OK) { | shdr[i].sh_size - sizeof(ctf_hdr)); | ||||
error = EIO; | if (ret != Z_OK) { | ||||
goto out; | printf("%s(%d): zlib uncompress returned %d\n", __func__, __LINE__, ret); | ||||
} | |||||
zs.avail_in = shdr[i].sh_size - sizeof(ctf_hdr); | |||||
zs.next_in = ((uint8_t *) raw) + sizeof(ctf_hdr); | |||||
zs.avail_out = sz - sizeof(ctf_hdr); | |||||
zs.next_out = ((uint8_t *) ctftab) + sizeof(ctf_hdr); | |||||
ret = inflate(&zs, Z_FINISH); | |||||
inflateEnd(&zs); | |||||
if (ret != Z_STREAM_END) { | |||||
printf("%s(%d): zlib inflate returned %d\n", __func__, __LINE__, ret); | |||||
error = EIO; | error = EIO; | ||||
goto out; | goto out; | ||||
} | } | ||||
} | } | ||||
/* Got the CTF data! */ | /* Got the CTF data! */ | ||||
ef->ctftab = ctftab; | ef->ctftab = ctftab; | ||||
ef->ctfcnt = shdr[i].sh_size; | ef->ctfcnt = shdr[i].sh_size; | ||||
Show All 35 Lines |
FreeBSD style discourages CamelCase. The variable should be called something like destlen instead.