]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
rgw/dedup: fixes an assertion failure from __snprintf_chk in fortified mode when...
authorGabriel BenHanokh <gbenhano@redhat.com>
Sun, 26 Oct 2025 15:51:53 +0000 (17:51 +0200)
committerGabriel BenHanokh <gbenhano@redhat.com>
Sun, 26 Oct 2025 15:51:53 +0000 (17:51 +0200)
The issue stems from buffer size validation in string operations.

Resolves: rhbz#2405986

Signed-off-by: Gabriel BenHanokh <gbenhano@redhat.com>
src/rgw/rgw_dedup_cluster.h

index 70017a006848672efe6f2371e3c95c3e6968a4dc..7a277bf91d986ed748cf1d7785379d6679b43975 100644 (file)
@@ -43,13 +43,13 @@ namespace rgw::dedup {
 
       //---------------------------------------------------------------------------
       void set_shard(uint16_t shard) {
-        int n = snprintf(this->buff + this->prefix_len, BUFF_SIZE, "%03x", shard);
+        int n = snprintf(this->buff + this->prefix_len, BUFF_SIZE - this->prefix_len, "%03x", shard);
         this->total_len = this->prefix_len + n;
       }
 
       //---------------------------------------------------------------------------
       static bool legal_oid_name(const std::string& oid) {
-        return ((oid.length() <= BUFF_SIZE) &&
+        return ((oid.length() < BUFF_SIZE) &&
                 (oid.starts_with(WORKER_SHARD_PREFIX)||oid.starts_with(MD5_SHARD_PREFIX)));
       }
       inline const char* get_buff() { return this->buff; }