]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
rgw: Add coverity annotations to ignore warnings about 32 bit time
authorVedansh Bhartia <vedanshbhartia@gmail.com>
Fri, 12 May 2023 06:06:38 +0000 (11:36 +0530)
committerVedansh Bhartia <vedanshbhartia@gmail.com>
Tue, 16 May 2023 15:54:37 +0000 (21:24 +0530)
There are two types of occurences of this warning:
1. Where time intervals are stored. These intervals are generally
   very small (like 30s for TOTP window duration), and are unlikely to
   overflow. These are marked as false positives.
2. Where time data is written to disk. Moving to 64 bit time would
   require significant work to ensure backwards compatibility. These
   shall be addressed via a separate PR. A bug addressing this has been
   opened at https://tracker.ceph.com/issues/61160

Signed-off-by: Vedansh Bhartia <vedanshbhartia@gmail.com>
src/rgw/driver/rados/rgw_trim_datalog.cc
src/rgw/driver/rados/rgw_trim_mdlog.cc
src/rgw/rgw_admin.cc
src/rgw/rgw_common.h
src/rgw/rgw_torrent.cc

index 72a160039cfefa8ba578b4122c043ca9e9cab189..88f840818b293568b50c4817a9ab78113109f8ef 100644 (file)
@@ -223,6 +223,9 @@ int DataLogTrimPollCR::operate(const DoutPrefixProvider *dpp)
       // request a 'data_trim' lock that covers the entire wait interval to
       // prevent other gateways from attempting to trim for the duration
       set_status("acquiring trim lock");
+
+      // interval is a small number and unlikely to overflow
+      // coverity[Y2K38_SAFETY:FALSE]
       yield call(new RGWSimpleRadosLockCR(store->svc()->rados->get_async_processor(), store,
                                           rgw_raw_obj(store->svc()->zone->get_zone_params().log_pool, lock_oid),
                                           "data_trim", lock_cookie,
index d8e19594aeaa2e3535ab1a1eed699dedc04245ad..4f813582032aaea3607ac0355896a9ddbb2bfefc 100644 (file)
@@ -668,6 +668,9 @@ int MetaTrimPollCR::operate(const DoutPrefixProvider *dpp)
 
       // prevent others from trimming for our entire wait interval
       set_status("acquiring trim lock");
+
+      // interval is a small number and unlikely to overflow
+      // coverity[Y2K38_SAFETY:FALSE]
       yield call(new RGWSimpleRadosLockCR(store->svc()->rados->get_async_processor(), store,
                                           obj, name, cookie, interval.sec()));
       if (retcode < 0) {
index 228e165647f508697061a1b6e819a53166ce9122..91a6b9fc9843b158a4a67e8999d3231e444ccb3e 100644 (file)
@@ -3036,6 +3036,9 @@ static int scan_totp(CephContext *cct, ceph::real_time& now, rados::cls::otp::ot
                              nullptr,
                              pins[0].c_str());
     if (rc != OATH_INVALID_OTP) {
+      // oath_totp_validate2 is an external library function, cannot fix internally
+      // Further, step_size is a small number and unlikely to overflow
+      // coverity[Y2K38_SAFETY:FALSE]
       rc = oath_totp_validate2(totp.seed_bin.c_str(), totp.seed_bin.length(),
                                start_time, 
                                step_size,
@@ -10371,6 +10374,8 @@ next:
       return -ret;
     }
 
+    // time offset is a small number and unlikely to overflow
+    // coverity[Y2K38_SAFETY:FALSE]
     config.time_ofs = time_ofs;
 
     /* now update the backend */
index 1b317b01b6f8afa9c81f2dffbcd30cab10d4317e..782d82a85aaa9cc5872b8b7d0438a3cdeaf576d6 100644 (file)
@@ -1292,6 +1292,8 @@ struct RGWBucketEnt {
   void encode(bufferlist& bl) const {
     ENCODE_START(7, 5, bl);
     uint64_t s = size;
+    // issue tracked here: https://tracker.ceph.com/issues/61160
+    // coverity[Y2K38_SAFETY]
     __u32 mt = ceph::real_clock::to_time_t(creation_time);
     std::string empty_str;  // originally had the bucket name here, but we encode bucket later
     encode(empty_str, bl);
index 0ad3f37f6e11b59b4ff6a3e9b452ff12aea5b770..af9c4a632dc984df0e7f5bdabcf03989ef68569c 100644 (file)
@@ -169,6 +169,8 @@ bufferlist RGWPutObj_Torrent::bencode_torrent(std::string_view filename) const
 
   // Only encode create_date and sha1 info. Other fields will be added during
   // GetObjectTorrent by rgw_read_torrent_file()
+  // issue tracked here: https://tracker.ceph.com/issues/61160
+  // coverity[Y2K38_SAFETY]
   bencode(CREATION_DATE, std::time(nullptr), bl);
 
   bencode_key(INFO_PIECES, bl);