diff options
author | Andreas Nilsson <andreas.nilsson@10gen.com> | 2013-05-30 19:39:57 +0100 |
---|---|---|
committer | Dan Pasette <dan@10gen.com> | 2013-05-30 18:00:54 -0400 |
commit | f159ee9995d9f2fdd8505579f27ba6aaf235d53e (patch) | |
tree | 6ae73c4cac0d47209b7d18034cb4bb384ceb70d7 | |
parent | 5ec76b730a94b6d8d072fab0a348e34debe72ea3 (diff) | |
download | mongo-f159ee9995d9f2fdd8505579f27ba6aaf235d53e.tar.gz |
SERVER-9808 Fix issues found in CoN static analysis
-rw-r--r-- | src/mongo/bson/bsonelement.h | 5 | ||||
-rw-r--r-- | src/mongo/db/curop.h | 4 | ||||
-rw-r--r-- | src/mongo/shell/shell_utils_launcher.cpp | 6 | ||||
-rw-r--r-- | src/mongo/util/processinfo_linux2.cpp | 2 |
4 files changed, 10 insertions, 7 deletions
diff --git a/src/mongo/bson/bsonelement.h b/src/mongo/bson/bsonelement.h index 8a72dfe66b7..00496165bc4 100644 --- a/src/mongo/bson/bsonelement.h +++ b/src/mongo/bson/bsonelement.h @@ -23,6 +23,7 @@ #include "mongo/bson/bsontypes.h" #include "mongo/bson/oid.h" +#include "mongo/platform/cstdint.h" #include "mongo/platform/float_utils.h" namespace mongo { @@ -240,8 +241,8 @@ namespace mongo { } // for objects the size *includes* the size of the size field - int objsize() const { - return *reinterpret_cast< const int* >( value() ); + size_t objsize() const { + return static_cast< const size_t >( *reinterpret_cast< const uint32_t* >( value() ) ); } /** Get a string's value. Also gives you start of the real data for an embedded object. diff --git a/src/mongo/db/curop.h b/src/mongo/db/curop.h index 7b4f30f7568..7d9fb2f63a0 100644 --- a/src/mongo/db/curop.h +++ b/src/mongo/db/curop.h @@ -101,8 +101,8 @@ namespace mongo { void set( const BSONObj& o ) { scoped_spinlock lk(_lock); - int sz = o.objsize(); - if ( sz > (int) sizeof(_buf) ) { + size_t sz = o.objsize(); + if ( sz > sizeof(_buf) ) { _reset(TOO_BIG_SENTINEL); } else { diff --git a/src/mongo/shell/shell_utils_launcher.cpp b/src/mongo/shell/shell_utils_launcher.cpp index 60af4f3a6cb..cfe679d4ea2 100644 --- a/src/mongo/shell/shell_utils_launcher.cpp +++ b/src/mongo/shell/shell_utils_launcher.cpp @@ -281,8 +281,10 @@ namespace mongo { break; } if ( last != buf ) { - strcpy( temp, last ); - strcpy( buf, temp ); + strncpy( temp, last, bufSize ); + temp[ bufSize-1 ] = '\0'; + strncpy( buf, temp, bufSize ); + buf[ bufSize-1 ] = '\0'; } else { verify( strlen( buf ) < bufSize ); diff --git a/src/mongo/util/processinfo_linux2.cpp b/src/mongo/util/processinfo_linux2.cpp index 98497f9c54d..5dbe9d67c64 100644 --- a/src/mongo/util/processinfo_linux2.cpp +++ b/src/mongo/util/processinfo_linux2.cpp @@ -49,7 +49,7 @@ namespace mongo { msgassertedNoTrace( 13538 , s.c_str() ); } int found = fscanf(f, - "%d %s %c " + "%d %127s %c " "%d %d %d %d %d " "%lu %lu %lu %lu %lu " "%lu %lu %ld %ld " /* utime stime cutime cstime */ |