summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/safe-browsing/ephy-gsb-service.c13
-rw-r--r--lib/safe-browsing/ephy-gsb-utils.c2
2 files changed, 9 insertions, 6 deletions
diff --git a/lib/safe-browsing/ephy-gsb-service.c b/lib/safe-browsing/ephy-gsb-service.c
index acac943cd..f5046a95a 100644
--- a/lib/safe-browsing/ephy-gsb-service.c
+++ b/lib/safe-browsing/ephy-gsb-service.c
@@ -352,8 +352,8 @@ ephy_gsb_service_update_thread (GTask *task,
double duration;
duration_str = json_object_get_string_member (body_obj, "minimumWaitDuration");
- /* Handle the trailing 's' character. */
- sscanf (duration_str, "%lfs", &duration);
+ /* g_ascii_strtod() ignores trailing characters, i.e. 's' character. */
+ duration = g_ascii_strtod (duration_str, &end);
self->next_list_updates_time = CURRENT_TIME + (gint64)ceil (duration);
}
@@ -640,7 +640,8 @@ ephy_gsb_service_update_full_hashes_sync (EphyGSBService *self,
list = ephy_gsb_threat_list_new (threat_type, platform_type, threat_entry_type, NULL);
hash = g_base64_decode (hash_b64, &length);
positive_duration = json_object_get_string_member (match, "cacheDuration");
- sscanf (positive_duration, "%lfs", &duration);
+ /* g_ascii_strtod() ignores trailing characters, i.e. 's' character. */
+ duration = g_ascii_strtod (positive_duration, NULL);
ephy_gsb_storage_insert_full_hash (self->storage, list, hash, floor (duration));
@@ -651,14 +652,16 @@ ephy_gsb_service_update_full_hashes_sync (EphyGSBService *self,
/* Update negative cache duration. */
duration_str = json_object_get_string_member (body_obj, "negativeCacheDuration");
- sscanf (duration_str, "%lfs", &duration);
+ /* g_ascii_strtod() ignores trailing characters, i.e. 's' character. */
+ duration = g_ascii_strtod (duration_str, NULL);
for (GList *l = prefixes; l && l->data; l = l->next)
ephy_gsb_storage_update_hash_prefix_expiration (self->storage, l->data, floor (duration));
/* Handle minimum wait duration. */
if (json_object_has_non_null_string_member (body_obj, "minimumWaitDuration")) {
duration_str = json_object_get_string_member (body_obj, "minimumWaitDuration");
- sscanf (duration_str, "%lfs", &duration);
+ /* g_ascii_strtod() ignores trailing characters, i.e. 's' character. */
+ duration = g_ascii_strtod (duration_str, NULL);
self->next_full_hashes_time = CURRENT_TIME + (gint64)ceil (duration);
ephy_gsb_storage_set_metadata (self->storage, "next_full_hashes_time", self->next_full_hashes_time);
}
diff --git a/lib/safe-browsing/ephy-gsb-utils.c b/lib/safe-browsing/ephy-gsb-utils.c
index a4e4ed165..06d6d376b 100644
--- a/lib/safe-browsing/ephy-gsb-utils.c
+++ b/lib/safe-browsing/ephy-gsb-utils.c
@@ -489,7 +489,7 @@ ephy_gsb_utils_rice_delta_decode (JsonObject *rde,
*num_items = 1 + num_entries;
items = g_malloc (*num_items * sizeof (guint32));
- sscanf (first_value_str, "%u", &items[0]);
+ items[0] = g_ascii_strtoull (first_value_str, NULL, 10);
if (num_entries == 0)
return items;