}
static const char *get_msgnum(struct client *client, const char *args,
- unsigned int *msgnum)
+ unsigned int *msgnum, bool thenspace)
{
unsigned int num;
"-ERR Message number too large: %s", args);
return NULL;
}
+ if (*args != (thenspace ? ' ' : '\0')) {
+ client_send_line(client,
+ "-ERR Noise after message number: %s", args);
+ return NULL;
+ }
if (num == 0 || num > client->messages_count) {
client_send_line(client,
"-ERR There's no message %u.", num);
}
static const char *get_size(struct client *client, const char *args,
- uoff_t *size)
+ uoff_t *size, bool thenspace)
{
uoff_t num;
args);
return NULL;
}
+ if (*args != (thenspace ? ' ' : '\0')) {
+ client_send_line(client, "-ERR Noise after size: %s", args);
+ return NULL;
+ }
while (*args == ' ') args++;
{
unsigned int msgnum;
- if (get_msgnum(client, args, &msgnum) == NULL)
+ if (get_msgnum(client, args, &msgnum, FALSE) == NULL)
return -1;
if (!client->deleted) {
} else {
unsigned int msgnum;
- if (get_msgnum(client, args, &msgnum) == NULL)
+ if (get_msgnum(client, args, &msgnum, FALSE) == NULL)
return -1;
client_send_line(client, "+OK %u %"PRIuUOFF_T, msgnum+1,
{
unsigned int msgnum;
- if (get_msgnum(client, args, &msgnum) == NULL)
+ if (get_msgnum(client, args, &msgnum, FALSE) == NULL)
return -1;
if (client->lowest_retr_pop3_msn > msgnum+1 ||
unsigned int msgnum;
uoff_t max_lines;
- args = get_msgnum(client, args, &msgnum);
+ args = get_msgnum(client, args, &msgnum, TRUE);
if (args == NULL)
return -1;
- if (get_size(client, args, &max_lines) == NULL)
+ if (get_size(client, args, &max_lines, FALSE) == NULL)
return -1;
client->top_count++;
} else {
unsigned int msgnum;
- if (get_msgnum(client, args, &msgnum) == NULL)
+ if (get_msgnum(client, args, &msgnum, FALSE) == NULL)
return -1;
seq = msgnum_to_seq(client, msgnum);