- Posts: 13
- Thank you received: 0
crash in command_interpreter() with part of Unicode-characters
- Pacifist
- Topic Author
- Offline
- New Member
-
Less
More
1 year 1 month ago #10028
by Pacifist
crash in command_interpreter() with part of Unicode-characters was created by Pacifist
I found that part of command_interpreter() cause crash with such commands like "ю", "юю" etc. It's occur there:
How can I repair that?
/* special case to handle one-character, non-alphanumeric commands; requested
* by many people so "'hi" or ";godnet test" is possible. Patch sent by Eric
* Green and Stefan Wasilewski. */
if (!isalpha(*argument)) {
arg[0] = argument[0];
arg[1] = '\0';
line = argument + 1;
} else
line = any_one_arg(argument, arg);
How can I repair that?
Please Log in or Create an account to join the conversation.
- thomas
-
- Offline
- Administrator
-
Less
More
- Posts: 816
- Thank you received: 159
1 year 1 month ago #10029
by thomas
Replied by thomas on topic crash in command_interpreter() with part of Unicode-characters
This is a special case where your characters trigger the "not alphanumeric" check. I figure this results in garbage in the resulting values.
The fix is to rewrite to using iswalpha instead, though I'm not sure how to go about it here.
Have you altered the code significantly to support utf-8 by now?
The fix is to rewrite to using iswalpha instead, though I'm not sure how to go about it here.
Have you altered the code significantly to support utf-8 by now?
Please Log in or Create an account to join the conversation.
- Pacifist
- Topic Author
- Offline
- New Member
-
Less
More
- Posts: 13
- Thank you received: 0
1 year 1 month ago #10030
by Pacifist
Replied by Pacifist on topic crash in command_interpreter() with part of Unicode-characters
Have you altered the code significantly to support utf-8 by now?
I'm use only this modification:
github.com/prool/tbamud/blob/7790abec579...590/src/comm.c#L1965
I'm use only this modification:
github.com/prool/tbamud/blob/7790abec579...590/src/comm.c#L1965
Please Log in or Create an account to join the conversation.
- thomas
-
- Offline
- Administrator
-
Less
More
- Posts: 816
- Thank you received: 159
1 year 1 month ago #10031
by thomas
Replied by thomas on topic crash in command_interpreter() with part of Unicode-characters
Ok, I understand why this happens now (thanks for the link to the code, it really helped). The issue is that the isalpha check returns false for the koi characters (are they utf-8-encoded here? I think so).
Instead ofI suggest you be explicit like this:
Instead of
if (!isalpha(*argument)) {
// somewhere near the function.
const char specialSingleChars = "*';";
if (strchr(specialSingleChars, *argument) != NULL) {
Please Log in or Create an account to join the conversation.
- Pacifist
- Topic Author
- Offline
- New Member
-
Less
More
- Posts: 13
- Thank you received: 0
1 year 1 month ago #10032
by Pacifist
And TbaMUD crashed soon after run.
I'm not programmer but think that problem in "ю" that it wide character and occupy more than argument[0].
Replied by Pacifist on topic crash in command_interpreter() with part of Unicode-characters
interpreter.c: In function ‘command_interpreter’:
interpreter.c:488:35: warning: initialization of ‘char’ from ‘char *’ makes integer from pointer without a cast [-Wint-conversion]
488 | const char specialSingleChars = "*';";
| ^~~~~
interpreter.c:500:14: warning: passing argument 1 of ‘strchr’ makes pointer from integer without a cast [-Wint-conversion]
500 | if (strchr(specialSingleChars, *argument) != NULL) {
| ^~~~~~~~~~~~~~~~~~
| |
| char
In file included from sysdep.h:74,
from interpreter.c:12:
/usr/include/string.h:226:14: note: expected ‘const char *’ but argument is of type ‘char’
226 | extern char *strchr (const char *__s, int __c)
| ^~~~~~
I'm not programmer but think that problem in "ю" that it wide character and occupy more than argument[0].
Please Log in or Create an account to join the conversation.
- thomas
-
- Offline
- Administrator
-
Less
More
- Posts: 816
- Thank you received: 159
1 year 1 month ago #10033
by thomas
Replied by thomas on topic crash in command_interpreter() with part of Unicode-characters
Ah yes, a typical browser code slip.
Missed a * there.
Missed a * there.
const char *specialSingleChars = "*';";
Please Log in or Create an account to join the conversation.
- Pacifist
- Topic Author
- Offline
- New Member
-
Less
More
- Posts: 13
- Thank you received: 0
1 year 1 month ago #10034
by Pacifist
Replied by Pacifist on topic crash in command_interpreter() with part of Unicode-characters
Thanks. It working now.
Please Log in or Create an account to join the conversation.
Time to create page: 0.105 seconds