projects
/
unix-history
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
tags
|
clone url
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
copy the length of the data, not the length of the buffer
[unix-history]
/
usr
/
src
/
lib
/
libc
/
db
/
btree
/
bt_utils.c
diff --git
a/usr/src/lib/libc/db/btree/bt_utils.c
b/usr/src/lib/libc/db/btree/bt_utils.c
index
07c67fb
..
ad25fe6
100644
(file)
--- a/
usr/src/lib/libc/db/btree/bt_utils.c
+++ b/
usr/src/lib/libc/db/btree/bt_utils.c
@@
-9,14
+9,16
@@
*/
#if defined(LIBC_SCCS) && !defined(lint)
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)bt_utils.c 5.
5
(Berkeley) %G%";
+static char sccsid[] = "@(#)bt_utils.c 5.
8
(Berkeley) %G%";
#endif /* LIBC_SCCS and not lint */
#include <sys/param.h>
#endif /* LIBC_SCCS and not lint */
#include <sys/param.h>
+
#include <db.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <db.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+
#include "btree.h"
/*
#include "btree.h"
/*
@@
-47,13
+49,14
@@
__bt_ret(t, e, key, data)
&data->size, &t->bt_dbuf, &t->bt_dbufsz))
return (RET_ERROR);
} else {
&data->size, &t->bt_dbuf, &t->bt_dbufsz))
return (RET_ERROR);
} else {
- if (bl->dsize > t->bt_dbufsz) {
- if ((p = realloc(t->bt_dbuf, bl->dsize)) == NULL)
+ /* Use +1 in case the first record retrieved is 0 length. */
+ if (bl->dsize + 1 > t->bt_dbufsz) {
+ if ((p = realloc(t->bt_dbuf, bl->dsize + 1)) == NULL)
return (RET_ERROR);
t->bt_dbuf = p;
return (RET_ERROR);
t->bt_dbuf = p;
- t->bt_dbufsz = bl->dsize;
+ t->bt_dbufsz = bl->dsize
+ 1
;
}
}
- bcopy(bl->bytes + bl->ksize, t->bt_dbuf,
t->bt_dbufsz
);
+ bcopy(bl->bytes + bl->ksize, t->bt_dbuf,
bl->dsize
);
data->size = bl->dsize;
}
data->data = t->bt_dbuf;
data->size = bl->dsize;
}
data->data = t->bt_dbuf;
@@
-72,7
+75,7
@@
__bt_ret(t, e, key, data)
t->bt_kbuf = p;
t->bt_kbufsz = bl->ksize;
}
t->bt_kbuf = p;
t->bt_kbufsz = bl->ksize;
}
- bcopy(bl->bytes, t->bt_kbuf,
t->bt_kbufsz
);
+ bcopy(bl->bytes, t->bt_kbuf,
bl->ksize
);
key->size = bl->ksize;
}
key->data = t->bt_kbuf;
key->size = bl->ksize;
}
key->data = t->bt_kbuf;