Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

CDRIVER-190 Check overflow - fix build

  • Loading branch information...
commit af3f91031656f8a8d6980ab40bd81a521d9f22e7 1 parent 6396e9d
@gjmurakami-10gen gjmurakami-10gen authored
View
6 SConstruct
@@ -24,7 +24,7 @@ AddOption('--seed-start-port',
AddOption('--c99',
dest='use_c99',
- default=False,
+ default=True,
action='store_true',
help='Compile with c99 (recommended for gcc)')
@@ -100,8 +100,8 @@ if os.sys.platform in ["darwin", "linux2"]:
env.Append( CPPFLAGS="-pedantic -Wall -ggdb -DMONGO_HAVE_STDINT" )
if not GetOption('standard_env'):
env.Append( CPPFLAGS=" -D_POSIX_SOURCE -D_DARWIN_C_SOURCE" )
- env.Append( CPPPATH=["/opt/local/include/"] )
- env.Append( LIBPATH=["/opt/local/lib/"] )
+ #env.Append( CPPPATH=["/opt/local/include/"] )
+ #env.Append( LIBPATH=["/opt/local/lib/"] )
if GetOption('use_c99'):
env.Append( CFLAGS=" -std=c99 " )
View
54 src/bcon.c
@@ -34,12 +34,6 @@ char *bcon_errstr[] = {
"bson finish error"
};
-static int bcon_error(bson *b, const bcon *bc, size_t i, bcon_error_t err) {
- b->err = err;
- b->errstr = bcon_errstr[err];
- return BCON_ERROR;
-}
-
bcon_error_t bson_append_bcon_array(bson *b, const bcon *bc);
/* should be static, but it used by test files */
@@ -376,51 +370,3 @@ void bcon_print(const bcon *bc) { /* prints internal representation, not JSON */
}
putchar('}');
}
-
-/* TODO - incomplete */
-static void bcon_json_print(bcon *bc, int n) {
- int t = 0;
- int key_value_count = 0;
- char *s;
- int end_of_data;
- bcon *bcp;
- putchar('{');
- for (end_of_data = 0, bcp = bc; !end_of_data; bcp++) {
- bcon bci = *bcp;
- switch (t) {
- case 'l':
- if (key_value_count & 0x1) putchar(':');
- printf("%ld", bci.l);
- t = 0;
- key_value_count++;
- break;
- case 's': /* fall through */
- default:
- s = bci.s;
- switch (*s) {
- case ':':
- ++s;
- t = *++s;
- break;
- case '{':
- if (key_value_count & 0x1) putchar(':');
- putchar(*s);
- key_value_count = 0;
- break;
- case '}':
- putchar(*s);
- key_value_count = 2;
- break;
- default:
- if (key_value_count & 0x1) putchar(':');
- else if (key_value_count > 1) putchar(',');
- printf("\"%s\"", s);
- t = 0;
- key_value_count++;
- break;
- }
- break;
- }
- }
- putchar('}');
-}
View
6 src/bson.c
@@ -758,7 +758,7 @@ static int bson_append_string_base( bson *b, const char *name,
size_t sl = len + 1;
if ( sl > INT32_MAX ) {
b->err = BSON_SIZE_OVERFLOW;
- // string too long
+ /* string too long */
return BSON_ERROR;
}
if ( bson_check_string( b, ( const char * )value, sl - 1 ) == BSON_ERROR )
@@ -802,11 +802,11 @@ MONGO_EXPORT int bson_append_code_w_scope_n( bson *b, const char *name,
size_t sl, size;
if ( !scope ) return BSON_ERROR;
sl = len + 1;
- if ( 4 + 4 + (long long)sl + (long long)bson_size( scope ) > (long long)INT32_MAX ) {
+ size = 4 + 4 + sl + bson_size( scope );
+ if ( size > (size_t)INT32_MAX ) {
b->err = BSON_SIZE_OVERFLOW;
return BSON_ERROR;
}
- size = 4 + 4 + sl + bson_size( scope );
if ( bson_append_estart( b, BSON_CODEWSCOPE, name, size ) == BSON_ERROR )
return BSON_ERROR;
bson_append32_as_int( b, ( int )size );
View
3  src/mongo.c
@@ -1411,6 +1411,7 @@ MONGO_EXPORT int mongo_cursor_next( mongo_cursor *cursor ) {
MONGO_EXPORT int mongo_cursor_destroy( mongo_cursor *cursor ) {
int result = MONGO_OK;
+ char *data;
if ( !cursor ) return result;
@@ -1425,7 +1426,7 @@ MONGO_EXPORT int mongo_cursor_destroy( mongo_cursor *cursor ) {
if( mm == NULL ) {
return MONGO_ERROR;
}
- char *data = &mm->data;
+ data = &mm->data;
data = mongo_data_append32( data, &ZERO );
data = mongo_data_append32( data, &ONE );
mongo_data_append64( data, &cursor->reply->fields.cursorID );
View
2  test/write_concern_test.c
@@ -36,7 +36,7 @@ void bson_dump( bson * b ) {
printf("\tstack: {");
delim = "";
for (i = 0; i < 32; i++) {
- printf("%s%d", delim, b->stack[i]);
+ printf("%s%zd", delim, b->stack[i]);
delim = ",";
}
printf("},\n");
Please sign in to comment.
Something went wrong with that request. Please try again.