Merge lp:~akopytov/percona-xtrabackup/bug977995 into lp:percona-xtrabackup/2.0

Proposed by Alexey Kopytov
Status: Merged
Approved by: Stewart Smith
Approved revision: no longer in the source branch.
Merged at revision: 420
Proposed branch: lp:~akopytov/percona-xtrabackup/bug977995
Merge into: lp:percona-xtrabackup/2.0
Diff against target: 63 lines (+22/-4)
1 file modified
src/xbstream_read.c (+22/-4)
To merge this branch: bzr merge lp:~akopytov/percona-xtrabackup/bug977995
Reviewer Review Type Date Requested Status
Stewart Smith (community) Approve
Review via email: mp+102565@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Alexey Kopytov (akopytov) wrote :
Revision history for this message
Stewart Smith (stewart) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/xbstream_read.c'
2--- src/xbstream_read.c 2012-02-10 20:05:56 +0000
3+++ src/xbstream_read.c 2012-04-18 18:06:22 +0000
4@@ -79,6 +79,10 @@
5 } \
6 } while (0)
7
8+/* Magic + flags + type + path len */
9+#define CHUNK_HEADER_CONSTANT_LEN ((sizeof(XB_STREAM_CHUNK_MAGIC) - 1) + \
10+ 1 + 1 + 4)
11+
12 xb_rstream_result_t
13 xb_stream_read_chunk(xb_rstream_t *stream, xb_rstream_chunk_t *chunk)
14 {
15@@ -86,23 +90,35 @@
16 uchar *ptr = tmpbuf;
17 uint pathlen;
18 size_t tlen;
19+ size_t tbytes;
20 ulonglong ullval;
21 ulong checksum_exp;
22 ulong checksum;;
23 File fd = stream->fd;
24
25+ xb_ad(sizeof(tmpbuf) >= CHUNK_HEADER_CONSTANT_LEN);
26+
27 /* This is the only place where we expect EOF, so read with my_read()
28 rather than F_READ() */
29- tlen = my_read(fd, tmpbuf, sizeof(XB_STREAM_CHUNK_MAGIC) + 5,
30- MYF(MY_WME));
31- if (tlen == 0) {
32+ tlen = CHUNK_HEADER_CONSTANT_LEN;
33+ while (tlen > 0) {
34+ tbytes = my_read(fd, ptr, tlen, MYF(MY_WME));
35+ if (tbytes == 0) {
36+ break;
37+ }
38+ ptr += tbytes;
39+ tlen -= tbytes;
40+ }
41+ if (tlen == CHUNK_HEADER_CONSTANT_LEN) {
42 return XB_STREAM_READ_EOF;
43- } else if (tlen < sizeof(XB_STREAM_CHUNK_MAGIC) + 4) {
44+ } else if (tlen > 0) {
45 msg("xb_stream_read_chunk(): unexpected end of stream at "
46 "offset 0x%llx.\n", stream->offset);
47 goto err;
48 }
49
50+ ptr = tmpbuf;
51+
52 /* Chunk magic value */
53 if (memcmp(tmpbuf, XB_STREAM_CHUNK_MAGIC, 8)) {
54 msg("xb_stream_read_chunk(): wrong chunk magic at offset "
55@@ -138,6 +154,8 @@
56 chunk->pathlen = pathlen;
57 stream->offset +=4;
58
59+ xb_ad((ptr + 4 - tmpbuf) == CHUNK_HEADER_CONSTANT_LEN);
60+
61 /* Path */
62 if (chunk->pathlen > 0) {
63 F_READ((uchar *) chunk->path, pathlen);

Subscribers

People subscribed via source and target branches