-
Notifications
You must be signed in to change notification settings - Fork 60
Fixes for various memory leaks and other issues #1176
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
vojtechtrefny
merged 50 commits into
storaged-project:master
from
vojtechtrefny:master_claude-issues-fixes
Mar 9, 2026
Merged
Changes from all commits
Commits
Show all changes
50 commits
Select commit
Hold shift + click to select a range
3c89b36
nvme: Fix loop variable reuse in namespace descriptor iteration
vojtechtrefny 6df1b98
s390: Fix fgetc comparison to use character '1' instead of integer 1
vojtechtrefny 731c1c8
lvm: Fix next_arg index in bd_lvm_vdo_pool_convert
vojtechtrefny b207c65
utils: Fix NULL dereference in bd_utils_dbus_service_available
vojtechtrefny 355c087
fs: Fix g_free(label) to g_free(*label) in get_uuid_label
vojtechtrefny dda8607
core: Fix bd_ensure_init to check all plugins, not just the last
vojtechtrefny f4e0219
core: Restore stub on dlsym failure in generated plugin loaders
vojtechtrefny 4fd7cb0
fs: Remove mnt_free_fs calls on table-owned fs pointers
vojtechtrefny 3e53fdd
lvm: Fix FEATURES_WRITECACHE index to distinguish from FEATURES_VDO
vojtechtrefny 59a237d
dm: Remove extraneous device argument in bd_dm_create_linear
vojtechtrefny e7fba91
crypto: Zero sensitive data before freeing in keyslot context
vojtechtrefny 87f55b1
crypto: Fix crypt_device leak in bd_crypto_luks_remove_key
vojtechtrefny 6498154
crypto: Fix key_buf leaks on error paths
vojtechtrefny e8e32a4
crypto: Fix strerror_l usage for ioctl error in OPAL support check
vojtechtrefny 879a4c6
crypto: Remove stale strerror_l from LUKS label type-check error
vojtechtrefny 9f2001d
crypto, part: Call freelocale before clearing c_locale on close
vojtechtrefny d326c61
core: Fix GKeyFile leak on config load failure
vojtechtrefny a136489
core: Free so_name strings before clearing on plugin reload
vojtechtrefny 270aa36
lvm: Fix NULL dereference of error parameter in bd_lvm_pvs
vojtechtrefny 22974a3
lvm: Fix g_prefix_error called on wrong variable in cache_create
vojtechtrefny 6744c04
mdraid: Remove g_hash_table_destroy call on NULL table
vojtechtrefny 26962ac
swap: Fix NULL+1 from strchr in bd_swap_swapstatus
vojtechtrefny 9d5a0ca
dm, mpath: Fix DM task resource leaks on early returns
vojtechtrefny 99a05ef
part: Fix type_name leak in get_part_type_guid_and_gpt_flags
vojtechtrefny 7de7a3d
nvme: Fix fd leak on _nvme_alloc failure in controller info
vojtechtrefny 0bf66fe
nvme: Fix out-of-bounds read on empty string in set_host_nqn/id
vojtechtrefny a37b2ba
utils: Fix GRegex leak in bd_utils_version_cmp error paths
vojtechtrefny 2d6cce2
utils: Fix GIOChannel leak in bd_utils_echo_str_to_file
vojtechtrefny 95e3c6c
lvm: Add missing vg_exported field to bd_lvm_vgs query
vojtechtrefny af6e9b8
mdraid: Handle failed UUID canonicalization in bd_md_detail
vojtechtrefny c01386c
mpath: Fix string array leak on error in get_map_deps
vojtechtrefny eb2e5d5
crypto: Remove incorrect (nullable) annotation from luks_resume context
vojtechtrefny f9375d1
crypto: Call report_finished on wipe success in integrity_format
vojtechtrefny 1c96961
lib: Add bounds checking and fix integer width in plugin operations
vojtechtrefny 1fe0d8f
lvm: Fix sscanf type mismatch with gboolean variable
vojtechtrefny 54b305d
lvm: Use exec_and_report_error in _vgcfgbackup_restore
vojtechtrefny 601c0eb
lvm: Fix PV list length truncation in bd_lvm_lvcreate
vojtechtrefny 73be8af
fs: Fix memory leak of intermediate g_autofree value in btrfs_get_info
vojtechtrefny 1bead0d
fs: Include colon in ntfsinfo strstr patterns to prevent NULL strchr
vojtechtrefny fad207c
fs: Fix copy-paste error in bd_fs_mount error message
vojtechtrefny 42a1e62
fs: Fix wrong error code when NTFS device is mounted
vojtechtrefny 48e92cf
fs: Set error on regex mismatch in btrfs_get_info
vojtechtrefny 5dab411
fs: Use g_new0 for BDFSBtrfsInfo allocation in btrfs_get_info
vojtechtrefny d57dd82
fs: Fix mount cache leak on mnt_table_set_cache failure
vojtechtrefny cef7550
swap: Fix double report_finished call in swapon/swapoff
vojtechtrefny 5ed2016
s390: Fix error message saying "online" in bd_s390_zfcp_offline
vojtechtrefny 24d9b9f
loop: Fix double /dev/ prefix in autoclear progress message
vojtechtrefny a7f6cb6
s390: Fix potential NULL dereference of error in bd_s390_zfcp_online
vojtechtrefny da5bc5c
part: Fix inconsistent progress tracking in set_part_name/set_part_uuid
vojtechtrefny 0176603
s390: Fix multiple memory leaks in bd_s390_zfcp_scsi_offline
vojtechtrefny File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -360,6 +360,7 @@ gboolean bd_crypto_init (void) { | |
| * | ||
| */ | ||
| void bd_crypto_close (void) { | ||
| freelocale (c_locale); | ||
| c_locale = (locale_t) 0; | ||
| crypt_set_log_callback (NULL, NULL, NULL); | ||
| crypt_set_debug_level (CRYPT_DEBUG_NONE); | ||
|
|
@@ -770,14 +771,17 @@ void bd_crypto_keyslot_context_free (BDCryptoKeyslotContext *context) { | |
| if (context == NULL) | ||
| return; | ||
|
|
||
| if (context->type == BD_CRYPTO_KEYSLOT_CONTEXT_TYPE_PASSPHRASE) | ||
| if (context->type == BD_CRYPTO_KEYSLOT_CONTEXT_TYPE_PASSPHRASE) { | ||
| explicit_bzero (context->u.passphrase.pass_data, context->u.passphrase.data_len); | ||
| g_free (context->u.passphrase.pass_data); | ||
| else if (context->type == BD_CRYPTO_KEYSLOT_CONTEXT_TYPE_KEYFILE) | ||
| } else if (context->type == BD_CRYPTO_KEYSLOT_CONTEXT_TYPE_KEYFILE) | ||
| g_free (context->u.keyfile.keyfile); | ||
| else if (context->type == BD_CRYPTO_KEYSLOT_CONTEXT_TYPE_KEYRING) | ||
| g_free (context->u.keyring.key_desc); | ||
| else if (context->type == BD_CRYPTO_KEYSLOT_CONTEXT_TYPE_VOLUME_KEY) | ||
| else if (context->type == BD_CRYPTO_KEYSLOT_CONTEXT_TYPE_VOLUME_KEY) { | ||
| explicit_bzero (context->u.volume_key.volume_key, context->u.volume_key.volume_key_size); | ||
| g_free (context->u.volume_key.volume_key); | ||
| } | ||
|
|
||
| g_free (context); | ||
| } | ||
|
|
@@ -1543,6 +1547,8 @@ gboolean bd_crypto_luks_add_key (const gchar *device, BDCryptoKeyslotContext *co | |
| } else { | ||
| g_set_error (&l_error, BD_CRYPTO_ERROR, BD_CRYPTO_ERROR_INVALID_CONTEXT, | ||
| "Only 'passphrase' and 'key file' context types are valid for LUKS add key."); | ||
| if (context->type == BD_CRYPTO_KEYSLOT_CONTEXT_TYPE_KEYFILE) | ||
| crypt_safe_free (key_buf); | ||
| bd_utils_report_finished (progress_id, l_error->message); | ||
| g_propagate_error (error, l_error); | ||
| crypt_free (cd); | ||
|
|
@@ -1642,6 +1648,7 @@ gboolean bd_crypto_luks_remove_key (const gchar *device, BDCryptoKeyslotContext | |
| if (ret < 0) { | ||
| g_set_error (&l_error, BD_CRYPTO_ERROR, BD_CRYPTO_ERROR_KEY_SLOT, | ||
| "Failed to determine key slot: %s", strerror_l (-ret, c_locale)); | ||
| crypt_free (cd); | ||
| bd_utils_report_finished (progress_id, l_error->message); | ||
| g_propagate_error (error, l_error); | ||
| return FALSE; | ||
|
|
@@ -1753,6 +1760,8 @@ gboolean bd_crypto_luks_change_key (const gchar *device, BDCryptoKeyslotContext | |
| } else { | ||
| g_set_error (&l_error, BD_CRYPTO_ERROR, BD_CRYPTO_ERROR_INVALID_CONTEXT, | ||
| "Only 'passphrase' and 'key file' context types are valid for LUKS change key."); | ||
| if (context->type == BD_CRYPTO_KEYSLOT_CONTEXT_TYPE_KEYFILE) | ||
| crypt_safe_free (key_buf); | ||
| bd_utils_report_finished (progress_id, l_error->message); | ||
| g_propagate_error (error, l_error); | ||
| crypt_free (cd); | ||
|
|
@@ -1951,7 +1960,7 @@ gboolean bd_crypto_luks_suspend (const gchar *luks_device, GError **error) { | |
| /** | ||
| * bd_crypto_luks_resume: | ||
| * @luks_device: LUKS device to resume | ||
| * @context: (nullable): key slot context (passphrase/keyfile/token...) for @luks_device | ||
| * @context: key slot context (passphrase/keyfile/token...) for @luks_device | ||
| * @error: (out) (optional): place to store error (if any) | ||
| * | ||
| * Supported @context types for this function: passphrase, key file | ||
|
|
@@ -2252,7 +2261,7 @@ gboolean bd_crypto_luks_set_label (const gchar *device, const gchar *label, cons | |
|
|
||
| if (g_strcmp0 (crypt_get_type (cd), CRYPT_LUKS2) != 0) { | ||
| g_set_error (error, BD_CRYPTO_ERROR, BD_CRYPTO_ERROR_TECH_UNAVAIL, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should be using |
||
| "Label can be set only on LUKS 2 devices: %s", strerror_l (-ret, c_locale)); | ||
| "Label can be set only on LUKS 2 devices."); | ||
| crypt_free (cd); | ||
| return FALSE; | ||
| } | ||
|
|
@@ -2965,11 +2974,10 @@ gboolean bd_crypto_integrity_format (const gchar *device, const gchar *algorithm | |
| ret = crypt_deactivate (cd, tmp_name); | ||
| if (ret != 0) | ||
| bd_utils_log_format (BD_UTILS_LOG_ERR, "Failed to deactivate temporary device %s", tmp_name); | ||
|
|
||
| } else | ||
| bd_utils_report_finished (progress_id, "Completed"); | ||
| } | ||
|
|
||
| crypt_free (cd); | ||
| bd_utils_report_finished (progress_id, "Completed"); | ||
|
|
||
| return TRUE; | ||
| } | ||
|
|
@@ -3909,7 +3917,7 @@ gboolean bd_crypto_opal_is_supported (const gchar *device, GError **error) { | |
| g_set_error (error, BD_CRYPTO_ERROR, BD_CRYPTO_ERROR_DEVICE, | ||
| "Failed to get opal status for the device '%s': %s", | ||
| device, | ||
| strerror_l (-ret, c_locale)); | ||
| strerror_l (errno, c_locale)); | ||
| close (fd); | ||
| return FALSE; | ||
| } | ||
|
|
@@ -4146,6 +4154,9 @@ gboolean bd_crypto_opal_reset_device (const gchar *device, BDCryptoKeyslotContex | |
| } | ||
|
|
||
| ret = crypt_wipe_hw_opal (cd, CRYPT_NO_SEGMENT, key_buf, buf_len, 0); | ||
| if (context->type == BD_CRYPTO_KEYSLOT_CONTEXT_TYPE_KEYFILE) | ||
| crypt_safe_free (key_buf); | ||
|
|
||
| if (ret != 0) { | ||
| g_set_error (&l_error, BD_CRYPTO_ERROR, BD_CRYPTO_ERROR_DEVICE, | ||
| "Failed to wipe LUKS HW-OPAL device: %s", strerror_l (-ret, c_locale)); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reject invalid plugin IDs instead of half-handling them.
These guards only cover values
>= BD_PLUGIN_UNDEF. NegativeBDPluginvalues can still reach array indexing and bit shifts, while out-of-range positive values are silently skipped. In the all-invalid case,bd_init()can returnTRUEwhile leaving the library uninitialized. Please treat any out-of-range plugin as a failed request.Minimal guard shape
Also applies to: 765-767, 781-783
🤖 Prompt for AI Agents