提交 add4b8fb 编写于 作者: O openeuler-ci-bot 提交者: Gitee

!492 Fix label-file reading bug

Merge pull request !492 from JingWoo/master
......@@ -26,6 +26,7 @@
#include "arguments.h"
#include "isula_libutils/log.h"
#include "utils.h"
#include "utils_string.h"
#include "console.h"
#include "create.h"
#include "commands.h"
......@@ -433,7 +434,6 @@ static int read_label_from_file(const char *path, size_t file_size, isula_contai
FILE *fp = NULL;
char *buf = NULL;
size_t len;
ssize_t num;
if (file_size == 0) {
return 0;
......@@ -444,14 +444,10 @@ static int read_label_from_file(const char *path, size_t file_size, isula_contai
return -1;
}
__fsetlocking(fp, FSETLOCKING_BYCALLER);
num = getline(&buf, &len, fp);
while (num != -1) {
size_t len = strlen(buf);
if (len == 1) {
num = getline(&buf, &len, fp);
while (getline(&buf, &len, fp) != -1) {
if (strlen(util_trim_space(buf)) == 0) {
continue;
}
buf[len - 1] = '\0';
if (!validate_label(buf)) {
COMMAND_ERROR("Invalid label '%s': empty name", buf);
ret = -1;
......@@ -462,7 +458,6 @@ static int read_label_from_file(const char *path, size_t file_size, isula_contai
ret = -1;
goto out;
}
num = getline(&buf, &len, fp);
}
out:
......
......@@ -125,7 +125,6 @@ static void find_selinux_fs_among_mounts(char **fs)
char *buf = NULL;
char **fields = NULL;
size_t len;
ssize_t num;
fp = fopen("/proc/self/mountinfo", "re");
if (fp == NULL) {
......@@ -134,16 +133,13 @@ static void find_selinux_fs_among_mounts(char **fs)
}
__fsetlocking(fp, FSETLOCKING_BYCALLER);
num = getline(&buf, &len, fp);
while (num != -1) {
while (getline(&buf, &len, fp) != -1) {
if (!strstr(buf, " - selinuxfs ")) {
num = getline(&buf, &len, fp);
continue;
}
fields = util_string_split((const char *)buf, ' ');
if (fields == NULL || util_array_len((const char **)fields) < MOUNT_POOINT_FIFTH_FIELD + 1) {
util_free_array(fields);
num = getline(&buf, &len, fp);
continue;
}
if (verify_selinuxfs_mount(fields[MOUNT_POOINT_FIFTH_FIELD - 1])) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册