lmdb: ITS#8066 fix mdb_load with large values.

Change-Id: I8e5320efbea2c457da5a6e7115f4a6c9c38f45c3
This commit is contained in:
Howard Chu 2015-02-26 21:36:04 +00:00 committed by Leo Yuriev
parent 602fdd16b9
commit 1981e8b6ee
2 changed files with 7 additions and 4 deletions

View File

@ -4,6 +4,7 @@ LMDB 0.9.15 Release Engineering
Fix txn init (ITS#7961,#7987) Fix txn init (ITS#7961,#7987)
Fix MDB_PREV_DUP (ITS#7955,#7671) Fix MDB_PREV_DUP (ITS#7955,#7671)
Fix compact of empty env (ITS#7956) Fix compact of empty env (ITS#7956)
Fix mdb_load with large values (ITS#8066)
Added workaround for fdatasync bug in ext3fs Added workaround for fdatasync bug in ext3fs
Build Build
Don't use -fPIC for static lib Don't use -fPIC for static lib

View File

@ -176,7 +176,7 @@ static int unhex(unsigned char *c2)
static int readline(MDB_val *out, MDB_val *buf) static int readline(MDB_val *out, MDB_val *buf)
{ {
unsigned char *c1, *c2, *end; unsigned char *c1, *c2, *end;
size_t len; size_t len, l2;
int c; int c;
if (!(mode & NOHDR)) { if (!(mode & NOHDR)) {
@ -206,6 +206,7 @@ badend:
c1 = buf->mv_data; c1 = buf->mv_data;
len = strlen((char *)c1); len = strlen((char *)c1);
l2 = len;
/* Is buffer too short? */ /* Is buffer too short? */
while (c1[len-1] != '\n') { while (c1[len-1] != '\n') {
@ -217,17 +218,18 @@ badend:
return EOF; return EOF;
} }
c1 = buf->mv_data; c1 = buf->mv_data;
c1 += buf->mv_size; c1 += l2;
if (fgets((char *)c1, buf->mv_size, stdin) == NULL) { if (fgets((char *)c1, buf->mv_size+1, stdin) == NULL) {
Eof = 1; Eof = 1;
badend(); badend();
return EOF; return EOF;
} }
buf->mv_size *= 2; buf->mv_size *= 2;
len = strlen((char *)c1); len = strlen((char *)c1);
l2 += len;
} }
c1 = c2 = buf->mv_data; c1 = c2 = buf->mv_data;
len = strlen((char *)c1); len = l2;
c1[--len] = '\0'; c1[--len] = '\0';
end = c1 + len; end = c1 + len;