mirror of
https://github.com/tbamud/tbamud.git
synced 2025-09-22 05:50:48 +02:00
remove undefined behaviour
This commit is contained in:
parent
59e2e4f180
commit
81e0eb009a
1 changed files with 4 additions and 2 deletions
|
@ -592,14 +592,16 @@ int get_number(char **name)
|
|||
{
|
||||
int i;
|
||||
char *ppos;
|
||||
char number[MAX_INPUT_LENGTH];
|
||||
char number[MAX_INPUT_LENGTH], tmp[MAX_INPUT_LENGTH];
|
||||
|
||||
*number = '\0';
|
||||
|
||||
if ((ppos = strchr(*name, '.')) != NULL) {
|
||||
*ppos++ = '\0';
|
||||
strlcpy(number, *name, sizeof(number));
|
||||
strcpy(*name, ppos); /* strcpy: OK (always smaller) */
|
||||
// avoid overlapping strings in strcpy which is undefined behaviour
|
||||
strcpy(tmp, ppos); /* strcpy: OK (always smaller) */
|
||||
strcpy(*name, tmp); /* strcpy: OK (always smaller) */
|
||||
|
||||
for (i = 0; *(number + i); i++)
|
||||
if (!isdigit(*(number + i)))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue