已开启
fix: add null checks and fix timer memory leak in fs_manager #4953
qianyang-yi创建于 19 天前
fix: add null checks and fix timer memory leak in fs_manager #4953
已开启
共 4 个文件变更+5-0
| @@ -219,6 +219,7 @@ INIT_STATIC int MkdirExt4UpperWorkDirs(const char *mnt) | |||
| 219 | 219 | ||
| 220 | int MountExt4Device(const char *dev, const char *mnt, bool isFirstMount) | 220 | int MountExt4Device(const char *dev, const char *mnt, bool isFirstMount) |
| 221 | { | 221 | { |
| 222 | + BEGET_ERROR_CHECK(dev != NULL && mnt != NULL, return -1, "dev or mnt path is null."); | ||
| 222 | if (isFirstMount) { | 223 | if (isFirstMount) { |
| 223 | SetSelinuxContext(mnt); | 224 | SetSelinuxContext(mnt); |
| 224 | } | 225 | } |
| @@ -868,6 +868,7 @@ static int SymlinkUtil(const char *source, const char *target) | |||
| 868 | 868 | ||
| 869 | int UpdateUserDataMEDevice(FstabItem *item) | 869 | int UpdateUserDataMEDevice(FstabItem *item) |
| 870 | { | 870 | { |
| 871 | + BEGET_ERROR_CHECK(item->deviceName != NULL, return -1, "deviceName is null."); | ||
| 871 | if (!ReadMEState()) { | 872 | if (!ReadMEState()) { |
| 872 | return 0; | 873 | return 0; |
| 873 | } | 874 | } |
| @@ -1181,6 +1182,7 @@ int FsManagerDmRemoveDevice(const char *devName) | |||
| 1181 | 1182 | ||
| 1182 | int MountOneWithFstabFile(const char *fstabFile, const char *devName, bool required) | 1183 | int MountOneWithFstabFile(const char *fstabFile, const char *devName, bool required) |
| 1183 | { | 1184 | { |
| 1185 | + BEGET_ERROR_CHECK(fstabFile != NULL && devName != NULL, return -1, "fstabFile or devName null."); | ||
| 1184 | bool isFile = fstabFile == NULL || *fstabFile == '\0'; | 1186 | bool isFile = fstabFile == NULL || *fstabFile == '\0'; |
| 1185 | BEGET_CHECK(!isFile, return -1); | 1187 | BEGET_CHECK(!isFile, return -1); |
| 1186 | 1188 | ||
| @@ -141,6 +141,7 @@ bool GetDmSnapshotStatus(const char *name, const char *targetType, StatusInfo *p | |||
| 141 | BEGET_LOGE("argc is null"); | 141 | BEGET_LOGE("argc is null"); |
| 142 | return false; | 142 | return false; |
| 143 | } | 143 | } |
| 144 | + BEGET_ERROR_CHECK(targetType != NULL, return false, "GetDmSnapshotStatus failed: targetType is null."); | ||
| 144 | size_t bufferLen = MAX_TABLE_LEN * sizeof(char); | 145 | size_t bufferLen = MAX_TABLE_LEN * sizeof(char); |
| 145 | int fd = open(DEVICE_MAPPER_PATH, O_RDWR | O_CLOEXEC); | 146 | int fd = open(DEVICE_MAPPER_PATH, O_RDWR | O_CLOEXEC); |
| 146 | BEGET_ERROR_CHECK(fd >= 0, return false, "open error %d", errno); | 147 | BEGET_ERROR_CHECK(fd >= 0, return false, "open error %d", errno); |
| @@ -113,6 +113,7 @@ static void RmdirTimer(Service *service, uint64_t timeout) | |||
| 113 | if (status != LE_SUCCESS) { | 113 | if (status != LE_SUCCESS) { |
| 114 | INIT_LOGE("Start service timer for service \' %s Rmdir \' failed, status = %d", serviceRmdir->name, status); | 114 | INIT_LOGE("Start service timer for service \' %s Rmdir \' failed, status = %d", serviceRmdir->name, status); |
| 115 | free(serviceRmdir->name); | 115 | free(serviceRmdir->name); |
| 116 | + free(serviceRmdir->timer); | ||
| 116 | free(serviceRmdir); | 117 | free(serviceRmdir); |
| 117 | } | 118 | } |
| 118 | } | 119 | } |