/* This is the only place where we expect EOF, so read with
xb_read_full() rather than F_READ() */
tbytes = xb_read_full(fd, ptr, CHUNK_HEADER_CONSTANT_LEN); if (tbytes == 0) { return XB_STREAM_READ_EOF;
} elseif (tbytes < CHUNK_HEADER_CONSTANT_LEN) {
msg("xb_stream_read_chunk(): unexpected end of stream at " "offset 0x%llx.", stream->offset); goto err;
}
ptr = tmpbuf;
/* Chunk magic value */ if (memcmp(tmpbuf, XB_STREAM_CHUNK_MAGIC, 8)) {
msg("xb_stream_read_chunk(): wrong chunk magic at offset " "0x%llx.", (ulonglong) stream->offset); goto err;
}
ptr += 8;
stream->offset += 8;
if (chunk->type == XB_CHUNK_TYPE_RENAME) {
F_READ(tmpbuf, 4);
size_t new_pathlen = uint4korr(tmpbuf); if (new_pathlen >= FN_REFLEN) {
msg("xb_stream_read_chunk(): path length (%lu) for new name of 'rename'" " chunk is too large", (ulong) new_pathlen); goto err;
}
chunk->length = new_pathlen;
stream->offset +=4;
} elseif (chunk->type == XB_CHUNK_TYPE_SEEK) {
F_READ(tmpbuf, 8);
chunk->offset = uint8korr(tmpbuf);
stream->offset += 8; return XB_STREAM_READ_CHUNK;
} else { /* Payload length */
F_READ(tmpbuf, 16);
ullval = uint8korr(tmpbuf); if (ullval > (ulonglong) SIZE_T_MAX) {
msg("xb_stream_read_chunk(): chunk length is too large at " "offset 0x%llx: 0x%llx.", (ulonglong) stream->offset,
ullval); goto err;
}
chunk->length = (size_t) ullval;
stream->offset += 8;
/* Payload offset */
ullval = uint8korr(tmpbuf + 8); if (ullval > (ulonglong) MY_OFF_T_MAX) {
msg("xb_stream_read_chunk(): chunk offset is too large at " "offset 0x%llx: 0x%llx.", (ulonglong) stream->offset,
ullval); goto err;
}
chunk->offset = (my_off_t) ullval;
stream->offset += 8;
}
/* Reallocate the buffer if needed, take into account trailing '\0' for
new file name in the case of XB_CHUNK_TYPE_RENAME */ if (chunk->length + 1 > chunk->buflen) {
chunk->data = my_realloc(PSI_NOT_INSTRUMENTED, chunk->data,
chunk->length + 1, MYF(MY_WME | MY_ALLOW_ZERO_PTR)); if (chunk->data == NULL) {
msg("xb_stream_read_chunk(): failed to increase buffer " "to %lu bytes.", (ulong) chunk->length + 1); goto err;
}
chunk->buflen = chunk->length + 1;
}
if (chunk->type == XB_CHUNK_TYPE_RENAME) { if (chunk->length == 0) {
msg("xb_stream_read_chunk(): failed to read new name for file to rename " ": %s", chunk->path); goto err;
}
F_READ(chunk->data, chunk->length);
stream->offset += chunk->length; reinterpret_cast<char *>(chunk->data)[chunk->length] = '\0';
++chunk->length;
} else { /* Checksum */
F_READ(tmpbuf, 4);
chunk->checksum = uint4korr(tmpbuf);
chunk->checksum_offset = stream->offset;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.