Commit f937dd72 authored by Bradley C. Kuszmaul's avatar Bradley C. Kuszmaul Committed by Yoni Fogel

Fixes #2487. close[t:2487]. One of the problems was a buffer overflow problem...

Fixes #2487. close[t:2487].  One of the problems was a buffer overflow problem because the header hadn't been extended.

git-svn-id: file:///svn/toku/tokudb@18900 c7de825b-a66e-492c-adef-691d508d4ae1
parent 55da2916
......@@ -880,7 +880,7 @@ static int loader_do_i (BRTLOADER bl,
skey.data = sval.data = pkey.data = pval.data = NULL; // set to NULL so that the final cleanup won't free them again.
}
if (rows.n_rows > 0) {
{
r = sort_and_write_rows(&rows, &fs, bl, dest_db, compare, &ec, allocation_for_read_pass);
if (r!=0) goto error;
}
......@@ -1014,6 +1014,13 @@ static void putbuf_int64 (struct dbuf *dbuf, unsigned long long v) {
}
static void putbuf_int32_at(struct dbuf *dbuf, int off, int v) {
const int nbytes = 4;
if (off+nbytes > dbuf->buflen) {
dbuf->buflen += dbuf->off + nbytes;
dbuf->buflen *= 2;
REALLOC_N(dbuf->buflen, dbuf->buf);
assert(dbuf->buf);
}
memcpy(dbuf->buf + off, &v, 4);
}
static void putbuf_int64_at(struct dbuf *dbuf, int off, unsigned long long v) {
......@@ -1560,6 +1567,8 @@ int write_file_to_dbfile (int outfile, FIDX infile, BRTLOADER bl, const struct d
est.exact = TRUE;
u_int64_t n_rows_remaining = bl->n_rows;
u_int64_t old_n_rows_remaining = bl->n_rows;
if (n_rows_remaining > 0) {
// If there were no rows then the infile may be invalid.
while (0==loader_read_row(infile, &key, &val, bl)) {
if (bl->user_said_stop) return bl->user_said_stop; // stops all those cilk subjobs if one of them got a "quit" from the poll.
if (lbuf->dbuf.off >= nodesize) {
......@@ -1588,6 +1597,7 @@ int write_file_to_dbfile (int outfile, FIDX infile, BRTLOADER bl, const struct d
n_rows_remaining--;
}
if (bl->user_said_stop) return bl->user_said_stop; // stops all those cilk subjobs if one of them got a "quit" from the poll.
}
allocate_node(&sts, lblock, est, lbuf->local_fingerprint);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment