libalpm/discspace.c: ensure mount points provide directories
In the very unlikely situtation where getmntent() and friends return non-null, but the mount directory is NULL, a null dereference could occur. It is unclear what the best course of action is in this case, so just move on to the next mount point. Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
parent
f996f30163
commit
ce528a2654
1 changed files with 12 additions and 0 deletions
|
@ -111,6 +111,10 @@ static alpm_list_t *mount_point_list(alpm_handle_t *handle)
|
|||
}
|
||||
|
||||
while((mnt = getmntent(fp))) {
|
||||
if(mnt->mnt_dir == NULL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
CALLOC(mp, 1, sizeof(alpm_mountpoint_t), RET_ERR(handle, ALPM_ERR_MEMORY, NULL));
|
||||
STRDUP(mp->mount_dir, mnt->mnt_dir, free(mp); RET_ERR(handle, ALPM_ERR_MEMORY, NULL));
|
||||
mp->mount_dir_len = strlen(mp->mount_dir);
|
||||
|
@ -134,6 +138,10 @@ static alpm_list_t *mount_point_list(alpm_handle_t *handle)
|
|||
}
|
||||
|
||||
while((ret = getmntent(fp, &mnt)) == 0) {
|
||||
if(mnt->mnt_mountp == NULL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
CALLOC(mp, 1, sizeof(alpm_mountpoint_t), RET_ERR(handle, ALPM_ERR_MEMORY, NULL));
|
||||
STRDUP(mp->mount_dir, mnt->mnt_mountp, free(mp); RET_ERR(handle, ALPM_ERR_MEMORY, NULL));
|
||||
mp->mount_dir_len = strlen(mp->mount_dir);
|
||||
|
@ -161,6 +169,10 @@ static alpm_list_t *mount_point_list(alpm_handle_t *handle)
|
|||
}
|
||||
|
||||
for(; entries-- > 0; fsp++) {
|
||||
if(fsp->f_mntonname == NULL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
CALLOC(mp, 1, sizeof(alpm_mountpoint_t), RET_ERR(handle, ALPM_ERR_MEMORY, NULL));
|
||||
STRDUP(mp->mount_dir, fsp->f_mntonname, free(mp); RET_ERR(handle, ALPM_ERR_MEMORY, NULL));
|
||||
mp->mount_dir_len = strlen(mp->mount_dir);
|
||||
|
|
Loading…
Add table
Reference in a new issue