Skip to content
Merged
Show file tree
Hide file tree
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 Mar 5, 2026
6df1b98
s390: Fix fgetc comparison to use character '1' instead of integer 1
vojtechtrefny Mar 5, 2026
731c1c8
lvm: Fix next_arg index in bd_lvm_vdo_pool_convert
vojtechtrefny Mar 5, 2026
b207c65
utils: Fix NULL dereference in bd_utils_dbus_service_available
vojtechtrefny Mar 5, 2026
355c087
fs: Fix g_free(label) to g_free(*label) in get_uuid_label
vojtechtrefny Mar 5, 2026
dda8607
core: Fix bd_ensure_init to check all plugins, not just the last
vojtechtrefny Mar 5, 2026
f4e0219
core: Restore stub on dlsym failure in generated plugin loaders
vojtechtrefny Mar 5, 2026
4fd7cb0
fs: Remove mnt_free_fs calls on table-owned fs pointers
vojtechtrefny Mar 5, 2026
3e53fdd
lvm: Fix FEATURES_WRITECACHE index to distinguish from FEATURES_VDO
vojtechtrefny Mar 5, 2026
59a237d
dm: Remove extraneous device argument in bd_dm_create_linear
vojtechtrefny Mar 5, 2026
e7fba91
crypto: Zero sensitive data before freeing in keyslot context
vojtechtrefny Mar 5, 2026
87f55b1
crypto: Fix crypt_device leak in bd_crypto_luks_remove_key
vojtechtrefny Mar 5, 2026
6498154
crypto: Fix key_buf leaks on error paths
vojtechtrefny Mar 5, 2026
e8e32a4
crypto: Fix strerror_l usage for ioctl error in OPAL support check
vojtechtrefny Mar 5, 2026
879a4c6
crypto: Remove stale strerror_l from LUKS label type-check error
vojtechtrefny Mar 5, 2026
9f2001d
crypto, part: Call freelocale before clearing c_locale on close
vojtechtrefny Mar 5, 2026
d326c61
core: Fix GKeyFile leak on config load failure
vojtechtrefny Mar 5, 2026
a136489
core: Free so_name strings before clearing on plugin reload
vojtechtrefny Mar 5, 2026
270aa36
lvm: Fix NULL dereference of error parameter in bd_lvm_pvs
vojtechtrefny Mar 5, 2026
22974a3
lvm: Fix g_prefix_error called on wrong variable in cache_create
vojtechtrefny Mar 5, 2026
6744c04
mdraid: Remove g_hash_table_destroy call on NULL table
vojtechtrefny Mar 5, 2026
26962ac
swap: Fix NULL+1 from strchr in bd_swap_swapstatus
vojtechtrefny Mar 5, 2026
9d5a0ca
dm, mpath: Fix DM task resource leaks on early returns
vojtechtrefny Mar 5, 2026
99a05ef
part: Fix type_name leak in get_part_type_guid_and_gpt_flags
vojtechtrefny Mar 5, 2026
7de7a3d
nvme: Fix fd leak on _nvme_alloc failure in controller info
vojtechtrefny Mar 5, 2026
0bf66fe
nvme: Fix out-of-bounds read on empty string in set_host_nqn/id
vojtechtrefny Mar 5, 2026
a37b2ba
utils: Fix GRegex leak in bd_utils_version_cmp error paths
vojtechtrefny Mar 5, 2026
2d6cce2
utils: Fix GIOChannel leak in bd_utils_echo_str_to_file
vojtechtrefny Mar 5, 2026
95e3c6c
lvm: Add missing vg_exported field to bd_lvm_vgs query
vojtechtrefny Mar 5, 2026
af6e9b8
mdraid: Handle failed UUID canonicalization in bd_md_detail
vojtechtrefny Mar 5, 2026
c01386c
mpath: Fix string array leak on error in get_map_deps
vojtechtrefny Mar 5, 2026
eb2e5d5
crypto: Remove incorrect (nullable) annotation from luks_resume context
vojtechtrefny Mar 5, 2026
f9375d1
crypto: Call report_finished on wipe success in integrity_format
vojtechtrefny Mar 5, 2026
1c96961
lib: Add bounds checking and fix integer width in plugin operations
vojtechtrefny Mar 6, 2026
1fe0d8f
lvm: Fix sscanf type mismatch with gboolean variable
vojtechtrefny Mar 6, 2026
54b305d
lvm: Use exec_and_report_error in _vgcfgbackup_restore
vojtechtrefny Mar 6, 2026
601c0eb
lvm: Fix PV list length truncation in bd_lvm_lvcreate
vojtechtrefny Mar 6, 2026
73be8af
fs: Fix memory leak of intermediate g_autofree value in btrfs_get_info
vojtechtrefny Mar 6, 2026
1bead0d
fs: Include colon in ntfsinfo strstr patterns to prevent NULL strchr
vojtechtrefny Mar 6, 2026
fad207c
fs: Fix copy-paste error in bd_fs_mount error message
vojtechtrefny Mar 6, 2026
42a1e62
fs: Fix wrong error code when NTFS device is mounted
vojtechtrefny Mar 6, 2026
48e92cf
fs: Set error on regex mismatch in btrfs_get_info
vojtechtrefny Mar 6, 2026
5dab411
fs: Use g_new0 for BDFSBtrfsInfo allocation in btrfs_get_info
vojtechtrefny Mar 6, 2026
d57dd82
fs: Fix mount cache leak on mnt_table_set_cache failure
vojtechtrefny Mar 6, 2026
cef7550
swap: Fix double report_finished call in swapon/swapoff
vojtechtrefny Mar 6, 2026
5ed2016
s390: Fix error message saying "online" in bd_s390_zfcp_offline
vojtechtrefny Mar 6, 2026
24d9b9f
loop: Fix double /dev/ prefix in autoclear progress message
vojtechtrefny Mar 6, 2026
a7f6cb6
s390: Fix potential NULL dereference of error in bd_s390_zfcp_online
vojtechtrefny Mar 6, 2026
da5bc5c
part: Fix inconsistent progress tracking in set_part_name/set_part_uuid
vojtechtrefny Mar 6, 2026
0176603
s390: Fix multiple memory leaks in bd_s390_zfcp_scsi_offline
vojtechtrefny Mar 6, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions scripts/boilerplate_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,10 @@ def get_loading_func(fn_infos, module_name):
# clear any previous error and load the function
ret += ' dlerror();\n'
ret += ' * (void**) (&_{0.name}) = dlsym(handle, "{0.name}");\n'.format(info)
ret += ' if ((error = dlerror()) != NULL)\n'
ret += ' bd_utils_log_format (BD_UTILS_LOG_WARNING, "failed to load {0.name}: %s", error);\n\n'.format(info)
ret += ' if ((error = dlerror()) != NULL) {\n'
ret += ' bd_utils_log_format (BD_UTILS_LOG_WARNING, "failed to load {0.name}: %s", error);\n'.format(info)
ret += ' _{0.name} = {0.name}_stub;\n'.format(info)
ret += ' }\n\n'

ret += ' return handle;\n'
ret += '}\n\n'
Expand Down
24 changes: 18 additions & 6 deletions src/lib/blockdev.c.in
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,10 @@ static gboolean process_config_file (const gchar *config_file, GSList **plugins_
gsize n_sonames = 0;

config = g_key_file_new ();
if (!g_key_file_load_from_file (config, config_file, G_KEY_FILE_NONE, error))
if (!g_key_file_load_from_file (config, config_file, G_KEY_FILE_NONE, error)) {
g_key_file_free (config);
return FALSE;
}

/* get sonames for each plugin (if specified) */
for (i=0; (i < BD_PLUGIN_UNDEF); i++) {
Expand Down Expand Up @@ -330,15 +332,19 @@ static gboolean load_plugins (BDPluginSpec **require_plugins, gboolean reload, g
unload_plugins ();
/* clean all so names and populate back those that are requested or the
defaults */
for (i=0; i < BD_PLUGIN_UNDEF; i++)
for (i=0; i < BD_PLUGIN_UNDEF; i++) {
g_free ((gchar *) plugins[i].spec.so_name);
plugins[i].spec.so_name = NULL;
}
}

if (require_plugins) {
/* set requested sonames */
for (i=0; *(require_plugins + i); i++) {
plugin_name = require_plugins[i]->name;
required_plugins_mask |= (1 << plugin_name);
if (plugin_name >= BD_PLUGIN_UNDEF)
continue;
required_plugins_mask |= ((guint64) 1 << plugin_name);
Comment on lines 343 to +347
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Reject invalid plugin IDs instead of half-handling them.

These guards only cover values >= BD_PLUGIN_UNDEF. Negative BDPlugin values 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 return TRUE while leaving the library uninitialized. Please treat any out-of-range plugin as a failed request.

Minimal guard shape
-            if (plugin_name >= BD_PLUGIN_UNDEF)
-                continue;
+            if ((gint) plugin_name < 0 || plugin_name >= BD_PLUGIN_UNDEF) {
+                requested_loaded = FALSE;
+                continue;
+            }
...
-    if (plugin >= BD_PLUGIN_UNDEF)
+    if ((gint) plugin < 0 || plugin >= BD_PLUGIN_UNDEF)
         return NULL;
...
-    if (plugin >= BD_PLUGIN_UNDEF)
+    if ((gint) plugin < 0 || plugin >= BD_PLUGIN_UNDEF)
         return NULL;

Also applies to: 765-767, 781-783

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/lib/blockdev.c.in` around lines 343 - 347, The loop over require_plugins
currently only skips plugin_name >= BD_PLUGIN_UNDEF but still allows negative
values and silently ignores out-of-range positives; change the guard in the loop
that builds required_plugins_mask to explicitly validate plugin_name is within
the valid enum range (0 <= plugin_name && plugin_name < BD_PLUGIN_UNDEF) before
using it for array indexing or bit shifts, and if any plugin_name is invalid
immediately treat the request as failed (propagate an error/return FALSE from
bd_init or the caller path used here) so invalid plugin IDs reject
initialization instead of being half-handled; update the same validation logic
in the other two locations noted (the blocks around the other two loops at
765-767 and 781-783) to use the same bounds check and failure handling.

if (require_plugins[i]->so_name) {
g_slist_free_full (plugins_sonames[plugin_name], (GDestroyNotify) g_free);
plugins_sonames[plugin_name] = NULL;
Expand All @@ -348,7 +354,7 @@ static gboolean load_plugins (BDPluginSpec **require_plugins, gboolean reload, g

/* now remove the defaults for plugins that are not required */
for (i=0; (i < BD_PLUGIN_UNDEF); i++)
if (!(required_plugins_mask & (1 << i))) {
if (!(required_plugins_mask & ((guint64) 1 << i))) {
/* plugin not required */
g_slist_free_full (plugins_sonames[i], (GDestroyNotify) g_free);
plugins_sonames[i] = NULL;
Expand All @@ -361,7 +367,7 @@ static gboolean load_plugins (BDPluginSpec **require_plugins, gboolean reload, g
for (i=0; (i < BD_PLUGIN_UNDEF); i++) {
/* if this plugin was required or all plugins were required, check if it
was successfully loaded or not */
if (!require_plugins || (required_plugins_mask & (1 << i))) {
if (!require_plugins || (required_plugins_mask & ((guint64) 1 << i))) {
#if !defined(__s390__) && !defined(__s390x__)
if (!require_plugins && (i == BD_PLUGIN_S390))
/* do not check the s390 plugin on different archs unless
Expand Down Expand Up @@ -496,7 +502,7 @@ gboolean bd_ensure_init (BDPluginSpec **require_plugins, BDUtilsLogFunc log_func
missing = !bd_is_plugin_available((*check_plugin)->name);
else
/* all plugins requested */
for (plugin=BD_PLUGIN_LVM; plugin != BD_PLUGIN_UNDEF; plugin++)
for (plugin=BD_PLUGIN_LVM; !missing && plugin != BD_PLUGIN_UNDEF; plugin++)
missing = !bd_is_plugin_available(plugin);

if (!missing) {
Expand Down Expand Up @@ -757,6 +763,9 @@ gboolean bd_is_plugin_available (BDPlugin plugin) {
* %NULL if none is loaded
*/
gchar* bd_get_plugin_soname (BDPlugin plugin) {
if (plugin >= BD_PLUGIN_UNDEF)
return NULL;

if (plugins[plugin].handle)
return g_strdup (plugins[plugin].spec.so_name);

Expand All @@ -770,5 +779,8 @@ gchar* bd_get_plugin_soname (BDPlugin plugin) {
* Returns: (transfer none): name of the plugin
*/
gchar* bd_get_plugin_name (BDPlugin plugin) {
if (plugin >= BD_PLUGIN_UNDEF)
return NULL;

return plugin_names[plugin];
}
2 changes: 1 addition & 1 deletion src/lib/plugin_apis/crypto.api
Original file line number Diff line number Diff line change
Expand Up @@ -1058,7 +1058,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
Expand Down
29 changes: 20 additions & 9 deletions src/plugins/crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should be using g_set_error_literal() instead as g_set_error() expects a format string.

"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;
}
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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));
Expand Down
6 changes: 2 additions & 4 deletions src/plugins/dm.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ gboolean bd_dm_is_tech_avail (BDDMTech tech, guint64 mode G_GNUC_UNUSED, GError
*/
gboolean bd_dm_create_linear (const gchar *map_name, const gchar *device, guint64 length, const gchar *uuid, GError **error) {
gboolean success = FALSE;
const gchar *argv[9] = {"dmsetup", "create", map_name, "--table", NULL, NULL, NULL, NULL, NULL};
const gchar *argv[8] = {"dmsetup", "create", map_name, "--table", NULL, NULL, NULL, NULL};

if (!check_deps (&avail_deps, DEPS_DMSETUP_MASK, deps, DEPS_LAST, &deps_check_lock, error))
return FALSE;
Expand All @@ -137,9 +137,7 @@ gboolean bd_dm_create_linear (const gchar *map_name, const gchar *device, guint6
if (uuid) {
argv[5] = "-u";
argv[6] = uuid;
argv[7] = device;
} else
argv[5] = device;
}

success = bd_utils_exec_and_report_error (argv, NULL, error);
g_free (table);
Expand Down
9 changes: 7 additions & 2 deletions src/plugins/fs/btrfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ BDFSBtrfsInfo* bd_fs_btrfs_get_info (const gchar *mpoint, GError **error) {
GRegex *regex = NULL;
GMatchInfo *match_info = NULL;
BDFSBtrfsInfo *ret = NULL;
g_autofree gchar *item = NULL;
gchar *item = NULL;
guint64 num_devices = 0;
guint64 min_size = 0;
gint scanned = 0;
Expand All @@ -351,12 +351,14 @@ BDFSBtrfsInfo* bd_fs_btrfs_get_info (const gchar *mpoint, GError **error) {

success = g_regex_match (regex, output, 0, &match_info);
if (!success) {
g_set_error (error, BD_FS_ERROR, BD_FS_ERROR_PARSE,
"Failed to parse btrfs filesystem information");
g_regex_unref (regex);
g_match_info_free (match_info);
return NULL;
}

ret = g_new (BDFSBtrfsInfo, 1);
ret = g_new0 (BDFSBtrfsInfo, 1);

ret->label = g_match_info_fetch_named (match_info, "label");
ret->uuid = g_match_info_fetch_named (match_info, "uuid");
Expand All @@ -368,14 +370,17 @@ BDFSBtrfsInfo* bd_fs_btrfs_get_info (const gchar *mpoint, GError **error) {
"Btrfs filesystem mounted on %s spans multiple devices (%"G_GUINT64_FORMAT")." \
"Filesystem plugin is not suitable for multidevice Btrfs volumes, please use " \
"Btrfs plugin instead.", mpoint, num_devices);
g_free (item);
g_match_info_free (match_info);
g_regex_unref (regex);
bd_fs_btrfs_info_free (ret);
return NULL;
}

g_free (item);
item = g_match_info_fetch_named (match_info, "size");
ret->size = g_ascii_strtoull (item, NULL, 0);
g_free (item);

g_match_info_free (match_info);
g_regex_unref (regex);
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/fs/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ get_uuid_label (const gchar *device, gchar **uuid, gchar **label, GError **error
"Failed to get UUID for the device '%s'", device);
blkid_free_probe (probe);
synced_close (fd);
g_free (label);
g_free (*label);
*label = NULL;
return FALSE;
}

Expand Down
8 changes: 3 additions & 5 deletions src/plugins/fs/mount.c
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,7 @@ gboolean bd_fs_mount (const gchar *device, const gchar *mountpoint, const gchar
}
} else {
g_set_error (error, BD_FS_ERROR, BD_FS_ERROR_FAIL,
"Unsupported argument for unmount: '%s'", (*extra_p)->opt);
"Unsupported argument for mount: '%s'", (*extra_p)->opt);
return FALSE;
}
}
Expand Down Expand Up @@ -811,6 +811,7 @@ gchar* bd_fs_get_mountpoint (const gchar *device, GError **error) {
g_set_error (error, BD_FS_ERROR, BD_FS_ERROR_FAIL,
"Failed to set cache for mount info table.");
mnt_free_table (table);
mnt_free_cache (cache);
return NULL;
}

Expand All @@ -832,14 +833,12 @@ gchar* bd_fs_get_mountpoint (const gchar *device, GError **error) {

target = mnt_fs_get_target (fs);
if (!target) {
mnt_free_fs (fs);
mnt_free_table (table);
mnt_free_cache (cache);
return NULL;
}

mountpoint = g_strdup (target);
mnt_free_fs (fs);
mnt_free_table (table);
mnt_free_cache (cache);
return mountpoint;
Expand Down Expand Up @@ -869,6 +868,7 @@ gboolean bd_fs_is_mountpoint (const gchar *path, GError **error) {
g_set_error (error, BD_FS_ERROR, BD_FS_ERROR_FAIL,
"Failed to set cache for mount info table.");
mnt_free_table (table);
mnt_free_cache (cache);
return FALSE;
}

Expand All @@ -890,13 +890,11 @@ gboolean bd_fs_is_mountpoint (const gchar *path, GError **error) {

target = mnt_fs_get_target (fs);
if (!target) {
mnt_free_fs (fs);
mnt_free_table (table);
mnt_free_cache (cache);
return FALSE;
}

mnt_free_fs (fs);
mnt_free_table (table);
mnt_free_cache (cache);
return TRUE;
Expand Down
8 changes: 4 additions & 4 deletions src/plugins/fs/ntfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ BDFSNtfsInfo* bd_fs_ntfs_get_info (const gchar *device, GError **error) {

mountpoint = bd_fs_get_mountpoint (device, &l_error);
if (mountpoint != NULL) {
g_set_error (error, BD_FS_ERROR, BD_FS_ERROR_NOT_MOUNTED,
g_set_error (error, BD_FS_ERROR, BD_FS_ERROR_FAIL,
"Can't get NTFS file system information for '%s': Device is mounted.", device);
return NULL;
} else {
Expand Down Expand Up @@ -403,7 +403,7 @@ BDFSNtfsInfo* bd_fs_ntfs_get_info (const gchar *device, GError **error) {
line_p = lines;

/* find the beginning of the (data) section we are interested in */
while (line_p && *line_p && !strstr (*line_p, "Cluster Size"))
while (line_p && *line_p && !strstr (*line_p, "Cluster Size:"))
line_p++;
if (!line_p || !(*line_p)) {
g_set_error (error, BD_FS_ERROR, BD_FS_ERROR_PARSE, "Failed to parse NTFS file system information");
Expand All @@ -417,7 +417,7 @@ BDFSNtfsInfo* bd_fs_ntfs_get_info (const gchar *device, GError **error) {
val_start++;
cluster_size = g_ascii_strtoull (val_start, NULL, 0);

while (line_p && *line_p && !strstr (*line_p, "Volume Size in Clusters"))
while (line_p && *line_p && !strstr (*line_p, "Volume Size in Clusters:"))
line_p++;
if (!line_p || !(*line_p)) {
g_set_error (error, BD_FS_ERROR, BD_FS_ERROR_PARSE, "Failed to parse NTFS file system information");
Expand All @@ -431,7 +431,7 @@ BDFSNtfsInfo* bd_fs_ntfs_get_info (const gchar *device, GError **error) {
val_start++;
ret->size = g_ascii_strtoull (val_start, NULL, 0) * cluster_size;

while (line_p && *line_p && !strstr (*line_p, "Free Clusters"))
while (line_p && *line_p && !strstr (*line_p, "Free Clusters:"))
line_p++;
if (!line_p || !(*line_p)) {
g_set_error (error, BD_FS_ERROR, BD_FS_ERROR_PARSE, "Failed to parse NTFS file system information");
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/loop.c
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ gboolean bd_loop_set_autoclear (const gchar *loop, gboolean autoclear, GError **
if (!g_str_has_prefix (loop, "/dev/"))
dev_loop = g_strdup_printf ("/dev/%s", loop);

msg = g_strdup_printf ("Started setting up the autoclear flag on the /dev/%s device",
msg = g_strdup_printf ("Started setting up the autoclear flag on the %s device",
dev_loop ? dev_loop : loop);
progress_id = bd_utils_report_started (msg);
g_free (msg);
Expand Down
Loading