Skip to content

Commit e032cf1

Browse files
IlanTruanovskypcolberg
authored andcommitted
Fixed CHECK_RETURN Coverity issues
lib/pkg_editor/src/pkg_editor.c:1604:3: Type: Unchecked return value from library (CHECKED_RETURN) lib/pkg_editor/src/pkg_editor.c:1584:3: Unchecked call to function 1. path: Condition "buffer != NULL", taking true branch. lib/pkg_editor/src/pkg_editor.c:1585:5: 2. path: Condition "input == NULL", taking true branch. lib/pkg_editor/src/pkg_editor.c:1585:5: 3. path: Falling through to end of if statement. lib/pkg_editor/src/pkg_editor.c:1588:3: 4. path: Falling through to end of if statement. lib/pkg_editor/src/pkg_editor.c:1594:3: 5. path: Condition "ret != 0", taking false branch. lib/pkg_editor/src/pkg_editor.c:1604:3: 6. check_return: Calling "mkdir(full_name, 493U)" without checking return value. This library function may fail and return an error code. lib/pkg_editor/src/pkg_editor.c:1651:7: Type: Unchecked return value from library (CHECKED_RETURN) lib/pkg_editor/src/pkg_editor.c:1584:3: Unchecked call to function 1. path: Condition "buffer != NULL", taking true branch. lib/pkg_editor/src/pkg_editor.c:1585:5: 2. path: Condition "input == NULL", taking true branch. lib/pkg_editor/src/pkg_editor.c:1585:5: 3. path: Falling through to end of if statement. lib/pkg_editor/src/pkg_editor.c:1588:3: 4. path: Falling through to end of if statement. lib/pkg_editor/src/pkg_editor.c:1594:3: 5. path: Condition "ret != 0", taking false branch. lib/pkg_editor/src/pkg_editor.c:1610:3: 6. path: Condition "z_info.strm.avail_in > 0", taking true branch. lib/pkg_editor/src/pkg_editor.c:1612:5: 7. path: Condition "!read_data(&info, 20UL /* sizeof (info) */, &z_info, input)", taking false branch. lib/pkg_editor/src/pkg_editor.c:1617:5: 8. path: Condition "info.magic != 3203399403U", taking false branch. lib/pkg_editor/src/pkg_editor.c:1625:5: 9. path: Condition "info.kind == PACK_END", taking false branch. lib/pkg_editor/src/pkg_editor.c:1630:5: 10. path: Condition "!read_data(name, info.name_length, &z_info, input)", taking false branch. lib/pkg_editor/src/pkg_editor.c:1638:5: 11. path: Condition "12288UL /* 3 * 4096 */ < out_dir_length", taking true branch. lib/pkg_editor/src/pkg_editor.c:1643:5: 12. path: Condition "full_name[12287 /* 3 * 4096 - 1 */] != 0", taking true branch. lib/pkg_editor/src/pkg_editor.c:1647:5: 13. path: Condition "info.kind == PACK_DIR", taking true branch. lib/pkg_editor/src/pkg_editor.c:1651:7: 14. check_return: Calling "mkdir(full_name, 493U)" without checking return value. This library function may fail and return an error code.
1 parent 70fa51a commit e032cf1

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

lib/pkg_editor/src/pkg_editor.c

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1514,6 +1514,17 @@ int acl_pkg_pack(const char *out_file, const char **input_files_dirs) {
15141514
return 1 /* success */;
15151515
}
15161516

1517+
static void create_dir(const char *dir_name) {
1518+
// Create output directory. We can ignore the error output since it will
1519+
// only delay the failure to the first attempt of creating a file in the
1520+
// (not) newly created directory.
1521+
#ifdef _WIN32
1522+
(void)CreateDirectory(dir_name, NULL);
1523+
#else
1524+
(void)mkdir(dir_name, 0755);
1525+
#endif
1526+
}
1527+
15171528
static int read_data(void *data, size_t size, ZInfo *z_info, FILE *in_fd) {
15181529
// We want to fill 'data' with 'size' bytes.
15191530
z_info->strm.next_out = data;
@@ -1593,12 +1604,7 @@ static int acl_pkg_unpack_buffer_or_file(const char *buffer, size_t buffer_size,
15931604
return 0;
15941605
}
15951606

1596-
// Create output directory (ignore any errors).
1597-
#ifdef _WIN32
1598-
CreateDirectory(full_name, NULL);
1599-
#else
1600-
mkdir(full_name, 0755);
1601-
#endif
1607+
create_dir(full_name);
16021608
full_name[out_dir_length] = '/';
16031609

16041610
// Process the file until we hit the PACK_END record (or finish the
@@ -1644,11 +1650,7 @@ static int acl_pkg_unpack_buffer_or_file(const char *buffer, size_t buffer_size,
16441650
full_name[FULL_NAME_LEN - 1] = '\0';
16451651

16461652
if (info.kind == PACK_DIR) {
1647-
#ifdef _WIN32
1648-
CreateDirectory(full_name, NULL);
1649-
#else
1650-
mkdir(full_name, 0755);
1651-
#endif
1653+
create_dir(full_name);
16521654
} else {
16531655
// Read file contents
16541656
FILE *out_file = fopen(full_name, "wb");

0 commit comments

Comments
 (0)