From 92000e8dc4c4b2ba5580581b82932100457883f8 Mon Sep 17 00:00:00 2001 From: adam Date: Fri, 22 Mar 2013 18:05:12 +0700 Subject: [PATCH] Fixed #54 --- .gitignore | 1 + Changelog | 4 ++++ luaejdb/luaejdb.iml | 1 - package.json | 2 +- tcejdb/bson.c | 2 +- tcejdb/configure | 18 +++++++++--------- tcejdb/configure.ac | 2 +- tcejdb/debian/changelog | 6 ++++++ tcejdb/testejdb/t2.c | 17 ++++++++++++++++- 9 files changed, 39 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index 75f8433..293223b 100644 --- a/.gitignore +++ b/.gitignore @@ -52,6 +52,7 @@ config.status /tcejdb/testejdb/t1 /tcejdb/testejdb/t2 /tcejdb/testejdb/t3 +/tcejdb/testejdb/t4 */nbproject/private/* diff --git a/Changelog b/Changelog index fcc9743..2925fe5 100644 --- a/Changelog +++ b/Changelog @@ -1,3 +1,7 @@ +2013-03-22 Anton Adamansky. + * Fixed number index crash #54 + - Release 1.0.67 + 2013-03-20 Anton Adamansky. * Python3 binding * Lua binding diff --git a/luaejdb/luaejdb.iml b/luaejdb/luaejdb.iml index 24790d5..a914152 100644 --- a/luaejdb/luaejdb.iml +++ b/luaejdb/luaejdb.iml @@ -2,7 +2,6 @@ - diff --git a/package.json b/package.json index 58c5f74..3bd4b3b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name" : "ejdb", - "version" : "1.0.64", + "version" : "1.0.67", "main" : "node/ejdb.js", "homepage" : "http://ejdb.org", "description" : "EJDB - Embedded JSON Database engine", diff --git a/tcejdb/bson.c b/tcejdb/bson.c index 6feafe6..1bffd76 100644 --- a/tcejdb/bson.c +++ b/tcejdb/bson.c @@ -1277,7 +1277,7 @@ EJDB_EXPORT void bson_numstr(char *str, int64_t i) { } EJDB_EXPORT int bson_numstrn(char *str, int maxbuf, int64_t i) { - if (i < 1000 && maxbuf > 4) { + if (i >= 0 && i < 1000 && maxbuf > 4) { memcpy(str, bson_numstrs[i], 4); return strlen(bson_numstrs[i]); } else { diff --git a/tcejdb/configure b/tcejdb/configure index 1c652e5..1f02042 100755 --- a/tcejdb/configure +++ b/tcejdb/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for tcejdb 1.0.66. +# Generated by GNU Autoconf 2.69 for tcejdb 1.0.67. # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. @@ -577,8 +577,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='tcejdb' PACKAGE_TARNAME='tcejdb' -PACKAGE_VERSION='1.0.66' -PACKAGE_STRING='tcejdb 1.0.66' +PACKAGE_VERSION='1.0.67' +PACKAGE_STRING='tcejdb 1.0.67' PACKAGE_BUGREPORT='' PACKAGE_URL='' @@ -1258,7 +1258,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures tcejdb 1.0.66 to adapt to many kinds of systems. +\`configure' configures tcejdb 1.0.67 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1319,7 +1319,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of tcejdb 1.0.66:";; + short | recursive ) echo "Configuration of tcejdb 1.0.67:";; esac cat <<\_ACEOF @@ -1426,7 +1426,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -tcejdb configure 1.0.66 +tcejdb configure 1.0.67 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -1724,7 +1724,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by tcejdb $as_me 1.0.66, which was +It was created by tcejdb $as_me 1.0.67, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -4893,7 +4893,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by tcejdb $as_me 1.0.66, which was +This file was extended by tcejdb $as_me 1.0.67, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -4946,7 +4946,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -tcejdb config.status 1.0.66 +tcejdb config.status 1.0.67 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/tcejdb/configure.ac b/tcejdb/configure.ac index 29a270e..226fcc1 100644 --- a/tcejdb/configure.ac +++ b/tcejdb/configure.ac @@ -11,7 +11,7 @@ test -n "$CPPFLAGS" && MYCPPFLAGS="$CPPFLAGS $MYCPPFLAGS" test -n "$LDFLAGS" && MYLDFLAGS="$LDFLAGS $MYLDFLAGS" # Package name -AC_INIT(tcejdb, 1.0.66) +AC_INIT(tcejdb, 1.0.67) # Package information MYLIBVER=9 diff --git a/tcejdb/debian/changelog b/tcejdb/debian/changelog index 42bef72..6b2d97a 100644 --- a/tcejdb/debian/changelog +++ b/tcejdb/debian/changelog @@ -1,3 +1,9 @@ +libtcejdb (1.0.67) unstable; urgency=low + + * Fixed number index crash #54 + + -- Anton Adamansky Fri, 22 Mar 2013 18:01:39 +0700 + libtcejdb (1.0.66) stable; urgency=low * Better BSON error reporting diff --git a/tcejdb/testejdb/t2.c b/tcejdb/testejdb/t2.c index 6d3ebbf..3630b18 100644 --- a/tcejdb/testejdb/t2.c +++ b/tcejdb/testejdb/t2.c @@ -13,6 +13,7 @@ #include "CUnit/Basic.h" #include #include "ejdb_private.h" +#include "debian/libtcejdb9-dev/usr/include/tcejdb/bson.h" #include /* @@ -4222,6 +4223,19 @@ void testTicket43() { tcxstrdel(log); } +void testTicket54() { + EJCOLL *coll = ejdbcreatecoll(jb, "ticket54", NULL); + CU_ASSERT_PTR_NOT_NULL_FATAL(coll); + bson b; + bson_oid_t oid; + bson_init(&b); + bson_append_long(&b, "value", -10000000L); + bson_finish(&b); + CU_ASSERT_TRUE(ejdbsavebson(coll, &b, &oid)); + bson_destroy(&b); + CU_ASSERT_TRUE(ejdbsetindex(coll, "value", JBIDXNUM)); +} + int main() { setlocale(LC_ALL, "en_US.UTF-8"); @@ -4290,7 +4304,8 @@ int main() { (NULL == CU_add_test(pSuite, "testTicket29", testTicket29)) || (NULL == CU_add_test(pSuite, "testTicket28", testTicket28)) || (NULL == CU_add_test(pSuite, "testTicket38", testTicket38)) || - (NULL == CU_add_test(pSuite, "testTicket43", testTicket43)) + (NULL == CU_add_test(pSuite, "testTicket43", testTicket43)) || + (NULL == CU_add_test(pSuite, "testTicket54", testTicket54)) ) { CU_cleanup_registry(); return CU_get_error(); -- 2.7.4