Bug #12707


Port OpenZFS Coverity Fixes

Added by Jason King almost 3 years ago. Updated almost 3 years ago.

zfs - Zettabyte File System
Start date:
Due date:
% Done:


Estimated time:
Gerrit CR:
External Bug:


Port of:

commit 5df39c1e43e8d903ef4317e505cf85e64ef7e172
From: luozhengzheng <>
Date: Fri, 23 Sep 2016 06:55:41 +0800
Subject: [PATCH] Fix coverity defects

1.coverity scan CID:147445 function zfs_do_send in zfs_main.c
Buffer not null terminated (BUFFER_SIZE_WARNING)

2.coverity scan CID:147443 function zfs_do_bookmark in zfs_main.c
Buffer not null terminated (BUFFER_SIZE_WARNING)

3.coverity scan CID:147660 function main in zinject.c
Passing string argv[0] of unknown size to strcpy
By the way, the leak of g_zfs is fixed.

4.coverity scan CID: 147442 function make_disks in zpool_vdev.c
Buffer not null terminated (BUFFER_SIZE_WARNING)

5.coverity scan CID: 147661 function main in dir_rd_update.c
passing string cp1 of unknown size to strcpy

Reviewed-by: Brian Behlendorf <>
Signed-off-by: luozhengzheng <>
Closes #5130

All of the changes are pretty reasonable.

Actions #1

Updated by Jason King almost 3 years ago

To test, I ran the zfs tests. All the expected tests passed, and the failures seen were all known bugs with existing issues filed.

Actions #2

Updated by Jason King almost 3 years ago

  • Description updated (diff)
Actions #3

Updated by Jason King almost 3 years ago

The original OpenZFS fix includes changes to zpool_vdev.c (item 4 from the original commit msg). The file is specific to ZoL (and the specific fix from the original OpenZFS commit is for dev), and isn't applicable to illumos.

The fix to dir_rd_update.c (item 5 from the original commit msg) doesn't appear to be used by anything, and appears to be dead code (and the fix here, as well as the existing code have some obvious bugs -- if it's to be used, those should all be fixed in their own issue).

Actions #4

Updated by Jason King almost 3 years ago

I went ahead and applied the dir_rd_update.c change as well (even though it appears to no longer be used by any zfs-tests). Build was still clean, and no change in the zfs-test results (all the expected ones pass, and the failures were all existing issues w/ tickets already filed).

Actions #5

Updated by Electric Monk almost 3 years ago

  • Status changed from New to Closed
  • % Done changed from 0 to 100

git commit 3382f241dd77fdfc4a9c4b03092e328924cd0c65

commit  3382f241dd77fdfc4a9c4b03092e328924cd0c65
Author: luozhengzheng <>
Date:   2020-05-18T17:43:55.000Z

    12707 Port OpenZFS Coverity Fixes
    Reviewed by: Brian Behlendorf <>
    Reviewed by: Yuri Pankov <>
    Reviewed by: Toomas Soome <>
    Reviewed by: Gergő Doma <>
    Portions contributed by: Jason King <>
    Approved by: Dan McDonald <>


Also available in: Atom PDF