summaryrefslogtreecommitdiff
path: root/src/core/wee-command.c
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2023-11-01 09:09:00 +0100
committerSébastien Helleu <flashcode@flashtux.org>2023-11-01 09:44:44 +0100
commitf53983bc790b8201431ee18fd5411311df6fabd6 (patch)
tree554d5548290934f0514e7742858b6aa9362b027d /src/core/wee-command.c
parent1dd535da5dc04852de48555fe222eb17881c48c2 (diff)
downloadweechat-f53983bc790b8201431ee18fd5411311df6fabd6.zip
core: display an error with command `/history N` when N is not a valid integer
Diffstat (limited to 'src/core/wee-command.c')
-rw-r--r--src/core/wee-command.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/core/wee-command.c b/src/core/wee-command.c
index 00631cc6a..f0361db58 100644
--- a/src/core/wee-command.c
+++ b/src/core/wee-command.c
@@ -3386,6 +3386,7 @@ COMMAND_CALLBACK(history)
{
struct t_gui_history *ptr_history;
int n, n_total, n_user, displayed;
+ char *error;
/* make C compiler happy */
(void) pointer;
@@ -3402,7 +3403,12 @@ COMMAND_CALLBACK(history)
return WEECHAT_RC_OK;
}
else
- n_user = atoi (argv[1]);
+ {
+ error = NULL;
+ n_user = (int)strtol (argv[1], &error, 10);
+ if (!error || error[0] || (n_user < 0))
+ COMMAND_ERROR;
+ }
}
if (buffer->history)