1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-12-23 15:33:25 +01:00

awhen atoi returns 0 on invalid input we don't want that to count as valid

This commit is contained in:
Jfreegman 2013-10-20 07:16:26 -04:00
parent 77de8dd116
commit 407d28bf5d
3 changed files with 9 additions and 10 deletions

View File

@ -283,7 +283,7 @@ static void chat_savefile(ToxWindow *self, ChatContext *ctx, Tox *m, uint8_t *nu
{
uint8_t filenum = atoi(num);
if (filenum < 0 || filenum >= MAX_FILES) {
if ((filenum == 0 && strcmp(num, "0")) || filenum >= MAX_FILES) {
wprintw(ctx->history, "No pending file transfers with that number.\n");
return;
}

View File

@ -31,7 +31,7 @@ void cmd_accept(WINDOW *window, ToxWindow *prompt, Tox *m, int argc, char (*argv
int num = atoi(argv[1]);
if (num < 0 || num >= MAX_FRIENDS_NUM) {
if ((num == 0 && strcmp(argv[1], "0"))|| num >= MAX_FRIENDS_NUM) {
wprintw(window, "No pending friend request with that number.\n");
return;
}
@ -214,7 +214,7 @@ void cmd_join(WINDOW *window, ToxWindow *prompt, Tox *m, int argc, char (*argv)[
int num = atoi(argv[1]);
if (num < 0 || num >= MAX_FRIENDS_NUM) {
if ((num == 0 && strcmp(argv[1], "0")) || num >= MAX_FRIENDS_NUM) {
wprintw(window, "No pending group chat invite with that number.\n");
return;
}
@ -314,7 +314,7 @@ void cmd_status(WINDOW *window, ToxWindow *prompt, Tox *m, int argc, char (*argv
{
uint8_t *msg = NULL;
if (argc == 2) {
if (argc >= 2) {
msg = argv[2];
if (msg[0] != '\"') {
@ -392,12 +392,11 @@ void execute(WINDOW *window, ToxWindow *prompt, Tox *m, char *u_cmd)
}
}
/* Copy from start to current position */
u_cmd[i] = '\0';
strcpy(args[num_args++], start);
if (!f_end)
++i;
u_cmd[i++] = '\0';
/* Copy from start to current position */
strcpy(args[num_args++], start);
}
/* match input to command list */

View File

@ -99,7 +99,7 @@ static void print_prompt_help(ToxWindow *self)
wprintw(self->window, " /accept <n> : Accept friend request\n");
wprintw(self->window, " /connect <ip> <port> <key> : Manually connect to a DHT server\n");
wprintw(self->window, " /status <type> <message> : Set your status with optional note\n");
wprintw(self->window, " /note <message> : Set a personal note\n");
wprintw(self->window, " /note <message> : Set a personal note\n");
wprintw(self->window, " /nick <nickname> : Set your nickname\n");
wprintw(self->window, " /join <n> : Join a group chat\n");
wprintw(self->window, " /groupchat : Create a group chat\n");