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

Free upon errors in config file(s) #133

Merged
merged 3 commits into from Mar 31, 2016
Merged

Free upon errors in config file(s) #133

merged 3 commits into from Mar 31, 2016

Conversation

gperciva
Copy link
Member

@gperciva gperciva commented Feb 3, 2016

Makes valgrind happy if there's any problems in parsing the config file. I'm not 100% happy with this PR since it's a bit awkward due to interfacing with libarchive code (longer comments in a52cd2e), but it's worth bringing to your attention.

@gperciva gperciva changed the title Free config error Free upon errors in config file(s) Feb 3, 2016
@gperciva
Copy link
Member Author

I'm going to work on a simpler/cleaner way of doing this.

@gperciva
Copy link
Member Author

This now consists of the first 2 commits of the original PR. It leaves a FILE open and a 8192-char buffer, both from tar/util.c process_lines(), but I'm still looking for cleaner ways of doing that part.


/* Find the start of the argument. */
conf_arg = conf_opt + optlen + 1;
conf_arg += strspn(conf_arg, " \t");
bsdtar->conf_arg = bsdtar->conf_opt + optlen + 1;
Copy link
Member

Choose a reason for hiding this comment

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

You're setting bsdtar->conf_arg to a string which was not allocated by malloc. What happens if we exit from this point?

@gperciva
Copy link
Member Author

Updated PR.

} else {
conf_arg_malloced = NULL;
bsdtar->conf_arg = NULL;
Copy link
Member

Choose a reason for hiding this comment

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

If we come here...

This moves the "allocated" version of conf_opt into the "global" bsdtar struct
because if there's a config file error, we'll exit inside dooption(), leaving
the previous local variable conf_opt un-freed.
This moves conf_arg_malloced into the "global" bsdtar struct because if
there's a config file error, we'll exit inside dooption(), leaving the
previous local variable conf_arg_malloced un-freed.
@gperciva
Copy link
Member Author

Updated, and should be easier to read / track history now.

@cperciva
Copy link
Member

Looks good to me. Should I merge now or did you want to rebase anything?

@gperciva
Copy link
Member Author

Go ahead and merge it now. More granularity in the history isn't a bad thing.

@cperciva cperciva merged commit 8b7b287 into master Mar 31, 2016
@gperciva gperciva deleted the free-config-error branch March 31, 2016 06:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants