diff options
author | Michael Adam <obnox@samba.org> | 2015-03-31 09:56:35 +0200 |
---|---|---|
committer | Vijay Bellur <vbellur@redhat.com> | 2015-04-02 03:05:39 -0700 |
commit | 7616738176f44cce8b6cfb0e1f65be8e1dc72f49 (patch) | |
tree | 3343eba1decb8ef78d85cbd8bccdc9308174f24a /libglusterfs | |
parent | 7b8637833d2bd07165cd36e6868f4e906dcb7c61 (diff) |
libgfdb: fix possible illegal memory access (CID 1288820)
Coverity CID 1288820
strncpy executed with a limit equal to the target array
size potentially leaves the target string not null terminated.
Make sure the copied string is a valid 0 terminated string.
Change-Id: I39ff6a64ca5b9e30562226dd34c5b06267b75b87
BUG: 789278
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-on: http://review.gluster.org/10063
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Poornima G <pgurusid@redhat.com>
Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>
Reviewed-by: Joseph Fernandes <josferna@redhat.com>
Tested-by: Joseph Fernandes <josferna@redhat.com>
Diffstat (limited to 'libglusterfs')
-rw-r--r-- | libglusterfs/src/gfdb/gfdb_sqlite3.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/libglusterfs/src/gfdb/gfdb_sqlite3.c b/libglusterfs/src/gfdb/gfdb_sqlite3.c index fa654840803..1bfeb811f6b 100644 --- a/libglusterfs/src/gfdb/gfdb_sqlite3.c +++ b/libglusterfs/src/gfdb/gfdb_sqlite3.c @@ -418,7 +418,8 @@ gf_sqlite3_init (dict_t *args, void **db_conn) { temp_str = NULL; GET_DB_PARAM_FROM_DICT(GFDB_STR_SQLITE3, args, GFDB_SQL_PARAM_DBPATH, temp_str, out); - strncpy(sql_conn->sqlite3_db_path, temp_str, PATH_MAX); + strncpy(sql_conn->sqlite3_db_path, temp_str, PATH_MAX-1); + sql_conn->sqlite3_db_path[PATH_MAX-1] = 0; is_dbfile_exist = (stat (sql_conn->sqlite3_db_path, &stbuf) == 0) ? _gf_true : _gf_false; |