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

Fix username lookup in case of missing USER environment variable #245

Merged
merged 2 commits into from
Oct 20, 2017
Merged

Fix username lookup in case of missing USER environment variable #245

merged 2 commits into from
Oct 20, 2017

Conversation

DariuszOstolski
Copy link
Contributor

@DariuszOstolski DariuszOstolski commented Sep 19, 2017

This commit fixes an issue with invalid-user in file prefix when USER environment variable is not defined.

@DariuszOstolski
Copy link
Contributor Author

Ping?

Copy link
Collaborator

@shinh shinh left a comment

Choose a reason for hiding this comment

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

I'll do these changes by myself.

#if defined(HAVE_PWD_H) && defined(HAVE_UNISTD_H)
uid_t uid;
struct passwd pwd;
struct passwd*result = NULL;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you add a whitespace right before "result"?

struct passwd* result = NULL

struct passwd*result = NULL;
char buffer[1024] = {'\0'};
uid = geteuid();
int pwuid_res = getpwuid_r(uid, &pwd, buffer, sizeof (buffer), &result);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you remove the whitespace between sizeof and buffer?

int pwuid_res = getpwuid_r(uid, &pwd, buffer, sizeof (buffer), &result);
if(pwuid_res == 0) {
g_my_user_name = pwd.pw_name;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please concatenate with the next line

char buffer[1024] = {'\0'};
uid = geteuid();
int pwuid_res = getpwuid_r(uid, &pwd, buffer, sizeof (buffer), &result);
if(pwuid_res == 0) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

A whitespace after "if"

@shinh
Copy link
Collaborator

shinh commented Oct 20, 2017

Sorry for the latency..

@shinh shinh merged commit ebf81ac into google:master Oct 20, 2017
@DariuszOstolski
Copy link
Contributor Author

Thanks

durswd pushed a commit to durswd/glog that referenced this pull request Sep 2, 2019
Fix username lookup in case of missing USER environment variable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants