summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Lambright <dlambrig@redhat.com>2015-08-11 15:36:26 -0400
committerDan Lambright <dlambrig@redhat.com>2015-08-13 04:38:53 -0700
commit6e055b7d7355cadbbf559ad4bed23872aa1743df (patch)
tree075126507ecaaa7c326fa4a2be3d118c7e072075
parentfb4955b796ab2f3236e00686ecc99e792f9c0f8b (diff)
cluster/tier: fix 64 bit issue with sql query using times
We overflowed when converting seconds to usecs in preperation for sql queries. The fix uses uint64_t throughout including subexpressions. Change-Id: I59bdb742197400dede97f54735b52030920b0d19 BUG: 1231268 Signed-off-by: Dan Lambright <dlambrig@redhat.com> Reviewed-on: http://review.gluster.org/11885 Tested-by: NetBSD Build System <jenkins@build.gluster.org> Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Joseph Fernandes
-rw-r--r--libglusterfs/src/gfdb/gfdb_data_store_types.h4
-rw-r--r--libglusterfs/src/gfdb/gfdb_sqlite3.c8
2 files changed, 6 insertions, 6 deletions
diff --git a/libglusterfs/src/gfdb/gfdb_data_store_types.h b/libglusterfs/src/gfdb/gfdb_data_store_types.h
index f70a43a20fc..f44c4872c5b 100644
--- a/libglusterfs/src/gfdb/gfdb_data_store_types.h
+++ b/libglusterfs/src/gfdb/gfdb_data_store_types.h
@@ -84,11 +84,11 @@ typedef enum gf_db_operation {
typedef struct timeval gfdb_time_t;
/*Convert time into seconds*/
-static inline long int
+static inline uint64_t
gfdb_time_2_usec(gfdb_time_t *gfdb_time)
{
GF_ASSERT(gfdb_time);
- return gfdb_time->tv_sec * GFDB_MICROSEC + gfdb_time->tv_usec;
+ return ((uint64_t) gfdb_time->tv_sec * GFDB_MICROSEC) + gfdb_time->tv_usec;
}
diff --git a/libglusterfs/src/gfdb/gfdb_sqlite3.c b/libglusterfs/src/gfdb/gfdb_sqlite3.c
index 5f4a0fc94ae..9fd2d181c45 100644
--- a/libglusterfs/src/gfdb/gfdb_sqlite3.c
+++ b/libglusterfs/src/gfdb/gfdb_sqlite3.c
@@ -665,7 +665,7 @@ gf_sqlite3_find_recently_changed_files(void *db_conn,
char *query_str = NULL;
gf_sql_connection_t *sql_conn = db_conn;
sqlite3_stmt *prep_stmt = NULL;
- long int from_time_usec = 0;
+ uint64_t from_time_usec = 0;
CHECK_SQL_CONN (sql_conn, out);
GF_VALIDATE_OR_GOTO(GFDB_STR_SQLITE3, query_callback, out);
@@ -759,7 +759,7 @@ gf_sqlite3_find_unchanged_for_time (void *db_conn,
char *query_str = NULL;
gf_sql_connection_t *sql_conn = db_conn;
sqlite3_stmt *prep_stmt = NULL;
- long int for_time_usec = 0;
+ uint64_t for_time_usec = 0;
CHECK_SQL_CONN (sql_conn, out);
GF_VALIDATE_OR_GOTO(GFDB_STR_SQLITE3, query_callback, out);
@@ -863,7 +863,7 @@ gf_sqlite3_find_recently_changed_files_freq (void *db_conn,
char *query_str = NULL;
gf_sql_connection_t *sql_conn = db_conn;
sqlite3_stmt *prep_stmt = NULL;
- long int from_time_usec = 0;
+ uint64_t from_time_usec = 0;
CHECK_SQL_CONN (sql_conn, out);
GF_VALIDATE_OR_GOTO(GFDB_STR_SQLITE3, query_callback, out);
@@ -993,7 +993,7 @@ gf_sqlite3_find_unchanged_for_time_freq (void *db_conn,
char *query_str = NULL;
gf_sql_connection_t *sql_conn = db_conn;
sqlite3_stmt *prep_stmt = NULL;
- long int for_time_usec = 0;
+ uint64_t for_time_usec = 0;
CHECK_SQL_CONN (sql_conn, out);
GF_VALIDATE_OR_GOTO (GFDB_STR_SQLITE3, query_callback, out);