Skip to content

Commit 11e6399

Browse files
Fix Coverity issue OVERRUN
lib/pkg_editor/src/pkg_editor.c:1411:9: Type: Out-of-bounds read (OVERRUN) lib/pkg_editor/src/pkg_editor.c:1323:3: 1. path: Condition "!append_data(&info, 20UL /* sizeof (info) */, z_info, of, 0)", taking false branch. lib/pkg_editor/src/pkg_editor.c:1330:3: 2. path: Condition "!append_data(dir_name, name_length, z_info, of, 0)", taking false branch. lib/pkg_editor/src/pkg_editor.c:1385:5: 3. path: Condition "8192UL /* 2 * 4096 */ < name_length", taking false branch. lib/pkg_editor/src/pkg_editor.c:1385:5: 4. cond_at_most: Checking "8192UL < name_length" implies that "info.name_length" and "name_length" may be up to 8192 on the false branch. lib/pkg_editor/src/pkg_editor.c:1398:5: 5. path: Condition "dir == NULL", taking false branch. lib/pkg_editor/src/pkg_editor.c:1404:5: 6. path: Condition "entry", taking true branch. lib/pkg_editor/src/pkg_editor.c:1406:7: 7. path: Condition "strcmp(entry->d_name, ".") != 0", taking true branch. lib/pkg_editor/src/pkg_editor.c:1406:7: 8. path: Condition "strcmp(entry->d_name, "..") != 0", taking true branch. lib/pkg_editor/src/pkg_editor.c:1411:9: 9. overrun-local: Overrunning array of 8192 bytes at byte offset 8192 by dereferencing pointer "full_name + name_length". [Note: The source code implementation of the function has been overridden by a builtin model.]
1 parent 8085c99 commit 11e6399

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/pkg_editor/src/pkg_editor.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1344,7 +1344,7 @@ static acl_pack_kind add_directory(const char *out_file, FILE *of,
13441344
#ifdef _WIN32
13451345
#define FULL_NAME_LENGTH (2 * MAX_PATH)
13461346
char full_name[FULL_NAME_LENGTH];
1347-
if (FULL_NAME_LENGTH < name_length) {
1347+
if (FULL_NAME_LENGTH <= name_length) {
13481348
fprintf(stderr, "acl_pkg_pack: Failed to write to %s: %s\n", out_file,
13491349
"Directory name too long");
13501350
return PACK_END;
@@ -1388,7 +1388,7 @@ static acl_pack_kind add_directory(const char *out_file, FILE *of,
13881388
struct dirent *entry;
13891389
#define FULL_NAME_LENGTH (2 * PATH_MAX)
13901390
char full_name[FULL_NAME_LENGTH];
1391-
if (FULL_NAME_LENGTH < name_length) {
1391+
if (FULL_NAME_LENGTH <= name_length) {
13921392
fprintf(stderr, "acl_pkg_pack: Failed to write to %s: %s\n", out_file,
13931393
"Directory name too long");
13941394
return PACK_END;

0 commit comments

Comments
 (0)