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 to declare missing MAXLOGNAME properly #3150

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

obache
Copy link
Contributor

@obache obache commented Aug 21, 2020

Use LOGIN_NAME_MAX if it is available for the condition.

@elliefm elliefm self-assigned this Sep 2, 2020
Copy link
Contributor

@elliefm elliefm left a comment

Choose a reason for hiding this comment

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

Sorry this took so long to look at. It looks good, thanks. I've identified one other change you might want to make while you're in there.

@@ -97,7 +98,11 @@ static void send_reply(struct sockaddr *sfrom, socklen_t sfromsiz, int status,
static int soc = 0; /* inetd (master) has handed us the port as stdin */

#ifndef MAXLOGNAME
# ifdef LOGIN_NAME_MAX
#define MAXLOGNAME (LOGIN_NAME_MAX - 1)
Copy link
Contributor

Choose a reason for hiding this comment

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

I went looking for the significance of this being LOGIN_NAME_MAX - 1 and not just LOGIN_NAME_MAX. Apparently LOGIN_NAME_MAX includes the terminating nil character. It's not immediately clear to me whether MAXLOGNAME does too, or not. But it doesn't matter anyway, because the only place this is used is here:

    char buf[MAXLOGNAME + MAXDOMNAME + MAX_MAILBOX_BUFFER];

which is MAXLOGNAME + 20 + 1024. But a few lines later:

        r = recvfrom(soc, buf, 511, 0, sfrom, &sfromsiz);

We only ever use 511 bytes of this buffer! Which is more than accommodated by the 1024 from MAX_MAILBOX_BUFFER, so unless MAXLOGNAME is negative its value is irrelevant.

Perhaps we should amend the recvfrom line to actually use the whole buffer, something like:

        r = recvfrom(soc, buf, sizeof(buf) - 1, 0, sfrom, &sfromsiz);

Do you want to do this too while you're in there? I'm not familiar with the fud protocol, so I don't know whether this would be a useful improvement in practice, but it's better code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought, but I'm not familiar too, so stay as it is.

To begin with, max length of user name (and domain name) should probably rely on Cyrus implementation (or email related RFC), not OS limitation....? mailbox and domain name are in full mailbox name, so just MAX_MAILBOX_BUFFER is sufficient...?

Use LOGIN_NAME_MAX if it is available for the condition.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants