Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ksmbd-tools: handle unset ret #323

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions tools/config_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include <glib.h>
#include <string.h>
#include <stdint.h>
#include <glib/gstdio.h>
#include <sys/stat.h>
#include <sys/types.h>
Expand Down Expand Up @@ -238,9 +239,13 @@ static int __mmap_parse_file(const char *path, process_entry_fn *process_entry)
goto out_unref;
}

for (len = g_mapped_file_get_length(file);
len > 0 && len != (size_t)-1;
len -= delim - contents + 1, contents = delim + 1) {
len = g_mapped_file_get_length(file);
if (len == 0 || len == SIZE_MAX) {
ret = -EINVAL;
goto out_close;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

g_mapped_file_unref() is not called on error handling ?. So, should we use goto out_unref instead of out_close ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah yes you're right. copy/paste mistake looks like.

}

while (len > 0) {
g_autofree char *entry = NULL;

delim = memchr(contents, '\n', len) ?: contents + len;
Expand All @@ -250,6 +255,7 @@ static int __mmap_parse_file(const char *path, process_entry_fn *process_entry)
process_entry == process_subauth_entry ||
process_entry == process_lock_entry)
goto out_unref;
len -= delim - contents + 1, contents = delim + 1;
}

out_unref:
Expand Down
Loading