-
Notifications
You must be signed in to change notification settings - Fork 284
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
Change default username to empty string #819
Conversation
|
c5ed268
to
9b57388
Compare
toxcore/group.c
Outdated
@@ -879,8 +879,8 @@ int group_peername(const Group_Chats *g_c, uint32_t groupnumber, int peernumber, | |||
} | |||
|
|||
if (g->group[peernumber].nick_len == 0) { | |||
memcpy(name, "Tox User", 8); | |||
return 8; | |||
memcpy(name, "", 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
memcpy here is a bit odd.
just use
name[0]='\0';
or memset it to all zeros for MAX_NAME_LENGTH
or just leave name alone since we are returning "0" as len
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and return 0;
is missing for early return
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see:
#768 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Um, @tox-user, do you realize that memory copy of 0 length doesn't copy anything? i.e. you might as well just remove that function call as it does nothing.
Also, Tox defines "empty" data, i.e. empty name, as arrays of 0 length, so just setting length to 0 should be enough, it shouldn't matter what the name array contains if the length is 0, it might as well just say "install gentoo" for all intents and purposes, because clients are supposed to read exactly 0 bytes of that name (i.e. none). Also, toxcore doesn't null-terminate data/strings in the API, but I guess you could.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm with @nurupo here, neither memcpy nor name[0]=0
are correct here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
memcpy is wrong.
why not be nice and put a null byte there. it is utf-8 ?
if (peer->nick_len == 0) {
name[0] = '\0';
return 0;
}
this seems the only correct version to me.
why be lazy and leave the buffer as is?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just return 0 is enough. If you get 0, you can read exactly 0 bytes from the buffer, so it doesn't matter what's in the first position that you never read.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still we could be nice about it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zoff99 that's not being nice, it's writing a byte into a buffer that contains no bytes. These values aren't C Strings that need to be \0
terminated.
The real question is « Why this piece of code exists? » Can't we just make sure the real peer name is ALWAYS in sync? EDIT: @tox-user Please sign your commits using GPG. ;) |
@nurupo Is it possible to set minimal name length == 1? |
@Diadlo will setting min len to 1 not break some clients, or at least compatibility? another question would be does a client need to distinguish between "name not yet known" and "empty string name" ? |
I think the cases "no name sent yet" or "no name set" might as well be treated the same. |
Or clients could stop acting in a stupid way and set the name at profile creation. As Ricin did, as Konv does. This MUST be enforced at toxcore level IMHO. Some sort of Just an idea but it would prevent corrupted profiles when a client does not handle everything right (as Ricin did in the start of it's life xD). Would be nice if we could all agree that Tox design about profiles handling/managment is fundamentally wrong and instead of trying to patch it we could make it better. |
9b57388
to
ad4cd8b
Compare
@zoff99 @nurupo @SkyzohKey |
@tox-user Just create a new email address that you use for github & set it as your principal email address so that you can sign and it'll says Verified. ;) |
Reviewed 1 of 1 files at r2. toxcore/group.c, line 882 at r1 (raw file): Previously, sudden6 wrote…
hh? the buffer must contain at least MAX_NAME_LENGTH bytes. the API says so. Comments from Reviewable |
@SkyzohKey I have a real email address in my github account and it's verified. I think github doesn't want me to use a fake email address in git. It wants me to use an email that is added to my github account, but it doesn't let me add my fake address and I don't know how I would verify it. Why do I even have to? I can't be the only one who uses a fake email in git and signs commits with a key that that uses the same fake email? It must be possible. |
@tox-user have you checked that your key is actually available on some major keyservers? ie have you tried to download it from there? |
Please enable the checkbox "Allow edits from maintainers." on the bottom right. Then I can rebase your PR and sign the commit myself. |
ad4cd8b
to
0f3c81d
Compare
0f3c81d
to
0c0977f
Compare
Maybe it shouldn't be allowed, or maybe there should be a special value for "no name received yet" like a error code enum in the API, or maybe toxcore should avoid telling a client that there is a user until it gets all information about the said user. I'm more in the favor of a special value / error code. |
Fixes #768.
This change is