char unit= optarg[strlen(optarg) - 1];
optarg[strlen(optarg) - 1]= '\0';
+ errno= 0;
ret= strtoll(optarg, (char **)NULL, 10);
+ if (errno != 0)
+ {
+ fprintf(stderr, "strtoll(optarg,..): %s\n", strerror(errno));
+ exit(1);
+ }
switch (unit)
{
break;
case OPT_CONCURRENCY: /* --concurrency or -c */
+ errno= 0;
ms_setting.nconns= (uint32_t)strtoul(optarg, (char **) NULL, 10);
- if (ms_setting.nconns <= 0)
+ if (ms_setting.nconns <= 0 || errno != 0)
{
fprintf(stderr, "Concurrency must be greater than 0.:-)\n");
exit(1);
break;
case OPT_EXECUTE_NUMBER: /* --execute_number or -x */
+ errno= 0;
ms_setting.exec_num= (int)strtol(optarg, (char **) NULL, 10);
- if (ms_setting.exec_num <= 0)
+ if (ms_setting.exec_num <= 0 || errno != 0)
{
fprintf(stderr, "Execute number must be greater than 0.:-)\n");
exit(1);
break;
case OPT_THREAD_NUMBER: /* --threads or -T */
+ errno= 0;
ms_setting.nthreads= (uint32_t)strtoul(optarg, (char **) NULL, 10);
- if (ms_setting.nthreads <= 0)
+ if (ms_setting.nthreads <= 0 || errno != 0)
{
fprintf(stderr, "Threads number must be greater than 0.:-)\n");
exit(1);
break;
case OPT_FIXED_LTH: /* --fixed_size or -X */
+ errno= 0;
ms_setting.fixed_value_size= (size_t)strtoull(optarg, (char **) NULL, 10);
- if ((ms_setting.fixed_value_size <= 0)
+ if ((ms_setting.fixed_value_size <= 0 || errno != 0)
|| (ms_setting.fixed_value_size > MAX_VALUE_SIZE))
{
fprintf(stderr, "Value size must be between 0 and 1M.:-)\n");
break;
case OPT_GETS_DIVISION: /* --division or -d */
+ errno= 0;
ms_setting.mult_key_num= (int)strtol(optarg, (char **) NULL, 10);
- if (ms_setting.mult_key_num <= 0)
+ if (ms_setting.mult_key_num <= 0 || errno != 0)
{
fprintf(stderr, "Multi-get key number must be greater than 0.:-)\n");
exit(1);
break;
case OPT_SOCK_PER_CONN: /* --conn_sock or -n */
+ errno= 0;
ms_setting.sock_per_conn= (uint32_t)strtoul(optarg, (char **) NULL, 10);
- if (ms_setting.sock_per_conn <= 0)
+ if (ms_setting.sock_per_conn <= 0 || errno != 0)
{
fprintf(stderr, "Number of socks of each concurrency "
"must be greater than 0.:-)\n");
break;
case OPT_REP_WRITE_SRV: /* --rep_write or -p */
+ errno= 0;
ms_setting.rep_write_srv= (uint32_t)strtoul(optarg, (char **) NULL, 10);
- if (ms_setting.rep_write_srv <= 0)
+ if (ms_setting.rep_write_srv <= 0 || errno != 0)
{
fprintf(stderr,
"Number of replication writing server must be greater "
verify(*key != NULL);
char *ptr= end + 1;
+ errno= 0;
unsigned long val= strtoul(ptr, &end, 10); /* flags */
+ verify(errno == 0);
verify(ptr != end);
verify(val == 0);
verify(end != NULL);
+ errno= 0;
*ndata = (ssize_t)strtoul(end, &end, 10); /* size */
+ verify(errno == 0);
verify(ptr != end);
verify(end != NULL);
while (end and *end != '\n' and isspace(*end))
char *ptr= buffer + 6 + strlen(key) + 1;
char *end;
+ errno= 0;
unsigned long val= strtoul(ptr, &end, 10); /* flags */
+ verify(errno == 0);
verify(ptr != end);
verify(val == 0);
verify(end != NULL);
+
+ errno= 0;
val= strtoul(end, &end, 10); /* size */
+ verify(errno == 0);
verify(ptr != end);
verify(val == datasize);
verify(end != NULL);
char *ptr= buffer + 6 + strlen(key) + 1;
char *end;
+ errno= 0;
unsigned long val= strtoul(ptr, &end, 10); /* flags */
+ verify(errno == 0);
verify(ptr != end);
verify(val == 0);
verify(end != NULL);
+
+ errno= 0;
val= strtoul(end, &end, 10); /* size */
+ verify(errno == 0);
verify(ptr != end);
verify(val == datasize);
verify(end != NULL);
+
+ errno= 0;
*cas= strtoul(end, &end, 10); /* cas */
+ verify(errno == 0);
verify(ptr != end);
verify(val == datasize);
verify(end != NULL);
char *nptr;
unsigned long value= strtoul(argv[optind], &nptr, 10);
- if ((nptr == argv[optind] and value == 0) or
+ if ((errno != 0) or
+ (nptr == argv[optind] and value == 0) or
(value == ULONG_MAX and errno == ERANGE) or
(value == 0 and errno == EINVAL))
{
*/
#include "mem_config.h"
+#include <cerrno>
#include <cstdio>
#include <cstring>
#include <getopt.h>
break;
case OPT_EXPIRE: /* --expire */
+ errno= 0;
opt_expire= (time_t)strtoll(optarg, (char **)NULL, 10);
+ if (errno != 0)
+ {
+ std::cerr << "Incorrect value passed to --expire: `" << optarg << "`" << std::cerr;
+ exit(EXIT_FAILURE);
+ }
break;
case OPT_USERNAME:
*/
#include "mem_config.h"
-#include <stdio.h>
-#include <unistd.h>
-#include <string.h>
+#include <cerrno>
+#include <cstdio>
+#include <cstring>
#include <getopt.h>
+#include <unistd.h>
+
#include <libmemcached-1.0/memcached.h>
#include <libmemcachedutil-1.0/util.h>
#include "client_options.h"
break;
case OPT_EXPIRE: /* --expire */
- opt_expire= (time_t)strtoll(optarg, (char **)NULL, 10);
+ errno= 0;
+ opt_expire= time_t(strtoll(optarg, (char **)NULL, 10));
+ if (errno != 0)
+ {
+ std::cerr << "Incorrect value passed to --expire: `" << optarg << "`" << std::cerr;
+ exit(EXIT_FAILURE);
+ }
break;
case OPT_USERNAME:
*/
#include "mem_config.h"
+#include <cerrno>
#include <cstdio>
#include <cstring>
#include <getopt.h>
break;
case OPT_EXPIRE: /* --expire */
+ errno= 0;
opt_expire= (time_t)strtoll(optarg, (char **)NULL, 10);
+ if (errno != 0)
+ {
+ std::cerr << "Incorrect value passed to --expire: `" << optarg << "`" << std::cerr;
+ exit(EXIT_FAILURE);
+ }
break;
case OPT_HASH:
#include <mem_config.h>
#include <cassert>
+#include <cerrno>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
-#include <sys/types.h>
#include <unistd.h>
#include <iostream>
break;
case OPT_SLAP_CONCURRENCY:
+ errno= 0;
opt_concurrency= (unsigned int)strtoul(optarg, (char **)NULL, 10);
+ if (errno != 0)
+ {
+ fprintf(stderr, "Invalid value for concurrency: %s\n", optarg);
+ exit(EXIT_FAILURE);
+ }
break;
case OPT_SLAP_EXECUTE_NUMBER:
+ errno= 0;
opt_execute_number= (unsigned int)strtoul(optarg, (char **)NULL, 10);
+ if (errno != 0)
+ {
+ fprintf(stderr, "Invalid value for execute: %s\n", optarg);
+ exit(EXIT_FAILURE);
+ }
break;
case OPT_SLAP_INITIAL_LOAD:
+ errno= 0;
opt_createial_load= (unsigned int)strtoul(optarg, (char **)NULL, 10);
+ if (errno != 0)
+ {
+ fprintf(stderr, "Invalid value for initial load: %s\n", optarg);
+ exit(EXIT_FAILURE);
+ }
break;
case OPT_QUIET:
#include <mem_config.h>
+#include <cerrno>
#include <cstdio>
#include <cstring>
#include <getopt.h>
#include <iostream>
#include <unistd.h>
+
#include <libmemcached-1.0/memcached.h>
#include "utilities.h"
break;
case OPT_EXPIRE:
+ errno= 0;
expiration= time_t(strtoul(optarg, (char **)NULL, 10));
+ if (errno != 0)
+ {
+ fprintf(stderr, "Invalid value for --expire: %s\n", optarg);
+ exit(EXIT_FAILURE);
+ }
break;
case OPT_QUIET:
{
token_t tokens[MAX_TOKENS];
ms_tokenize_command(command, tokens, MAX_TOKENS);
+ errno= 0;
value_len= strtol(tokens[VALUELEN_TOKEN].value, NULL, 10);
+ if (errno != 0)
+ {
+ printf("<%d ERROR %s\n", c->sfd, strerror(errno));
+ }
c->currcmd.key_prefix= *(uint64_t *)tokens[KEY_TOKEN].value;
/*
ptr++;
+ errno= 0;
port= (in_port_t) strtoul(ptr, (char **)NULL, 10);
+ if (errno != 0)
+ {
+ memcached_server_free(servers);
+ return NULL;
+ }
ptr2= index(ptr, ' ');
if (! ptr2)
if (ptr2)
{
ptr2++;
- weight = (uint32_t) strtoul(ptr2, (char **)NULL, 10);
+ errno= 0;
+ weight= uint32_t(strtoul(ptr2, (char **)NULL, 10));
+ if (errno != 0)
+ {
+ memcached_server_free(servers);
+ return NULL;
+ }
}
}
servers= memcached_server_list_append_with_weight(servers, buffer, port, weight, &rc);
if (isspace(*begin_ptr))
+ {
begin_ptr++;
+ }
}
return servers;
}
for (next_ptr= string_ptr; isdigit(*string_ptr); string_ptr++) {};
+ errno= 0;
result->item_flags= (uint32_t) strtoul(next_ptr, &string_ptr, 10);
- if (end_ptr == string_ptr)
+ if (errno != 0 or end_ptr == string_ptr)
{
goto read_error;
}
}
for (next_ptr= string_ptr; isdigit(*string_ptr); string_ptr++) {};
+ errno= 0;
value_length= (size_t)strtoull(next_ptr, &string_ptr, 10);
- if (end_ptr == string_ptr)
+ if (errno != 0 or end_ptr == string_ptr)
{
goto read_error;
}
{
string_ptr++;
for (next_ptr= string_ptr; isdigit(*string_ptr); string_ptr++) {};
+ errno= 0;
result->item_cas= strtoull(next_ptr, &string_ptr, 10);
}
- if (end_ptr < string_ptr)
+ if (errno != 0 or end_ptr < string_ptr)
{
goto read_error;
}
char *response_ptr= index(buffer, ' ');
char *endptr;
+ errno= 0;
long int version= strtol(response_ptr, &endptr, 10);
- if (version == LONG_MIN or version == LONG_MAX or errno == EINVAL or version > UINT8_MAX or version == 0)
+ if (errno != 0 or version == LONG_MIN or version == LONG_MAX or version > UINT8_MAX or version == 0)
{
instance->major_version= instance->minor_version= instance->micro_version= UINT8_MAX;
return memcached_set_error(*instance, MEMCACHED_UNKNOWN_READ_FAILURE, MEMCACHED_AT, memcached_literal_param("strtol() failed to parse major version"));
instance->major_version= uint8_t(version);
endptr++;
+ errno= 0;
version= strtol(endptr, &endptr, 10);
- if (version == LONG_MIN or version == LONG_MAX or errno == EINVAL or version > UINT8_MAX)
+ if (errno != 0 or version == LONG_MIN or version == LONG_MAX or version > UINT8_MAX)
{
instance->major_version= instance->minor_version= instance->micro_version= UINT8_MAX;
return memcached_set_error(*instance, MEMCACHED_UNKNOWN_READ_FAILURE, MEMCACHED_AT, memcached_literal_param("strtol() failed to parse minor version"));
instance->minor_version= uint8_t(version);
endptr++;
+ errno= 0;
version= strtol(endptr, &endptr, 10);
- if (version == LONG_MIN or version == LONG_MAX or errno == EINVAL or version > UINT8_MAX)
+ if (errno != 0 or version == LONG_MIN or version == LONG_MAX or version > UINT8_MAX)
{
instance->major_version= instance->minor_version= instance->micro_version= UINT8_MAX;
return memcached_set_error(*instance, MEMCACHED_UNKNOWN_READ_FAILURE, MEMCACHED_AT, memcached_literal_param("strtol() failed to parse micro version"));
case '8': /* INCR/DECR response */
case '9': /* INCR/DECR response */
{
+ errno= 0;
unsigned long long int auto_return_value= strtoull(buffer, (char **)NULL, 10);
if (auto_return_value == ULLONG_MAX and errno == ERANGE)
return memcached_set_error(*instance, MEMCACHED_UNKNOWN_READ_FAILURE, MEMCACHED_AT,
memcached_literal_param("Numeric response was out of range"));
}
+ else if (errno != 0)
+ {
+ result->numeric_value= UINT64_MAX;
+ return memcached_set_error(*instance, MEMCACHED_UNKNOWN_READ_FAILURE, MEMCACHED_AT,
+ memcached_literal_param("Numeric response was out of range"));
+ }
result->numeric_value= uint64_t(auto_return_value);
}
char *endptr;
+ errno= 0;
long int version= strtol(version_buffer, &endptr, 10);
- if (version == LONG_MIN or version == LONG_MAX or errno == EINVAL or version > UINT8_MAX or version == 0)
+ if (errno != 0 or version == LONG_MIN or version == LONG_MAX or version > UINT8_MAX or version == 0)
{
instance->major_version= instance->minor_version= instance->micro_version= UINT8_MAX;
return memcached_set_error(*instance, MEMCACHED_UNKNOWN_READ_FAILURE, MEMCACHED_AT, memcached_literal_param("strtol() failed to parse major version"));
instance->major_version= uint8_t(version);
endptr++;
+ errno= 0;
version= strtol(endptr, &endptr, 10);
- if (version == LONG_MIN or version == LONG_MAX or errno == EINVAL or version > UINT8_MAX)
+ if (errno != 0 or version == LONG_MIN or version == LONG_MAX or version > UINT8_MAX)
{
instance->major_version= instance->minor_version= instance->micro_version= UINT8_MAX;
return memcached_set_error(*instance, MEMCACHED_UNKNOWN_READ_FAILURE, MEMCACHED_AT, memcached_literal_param("strtol() failed to parse minor version"));
instance->minor_version= uint8_t(version);
endptr++;
+ errno= 0;
version= strtol(endptr, &endptr, 10);
- if (version == LONG_MIN or version == LONG_MAX or errno == EINVAL or version > UINT8_MAX)
+ if (errno != 0 or version == LONG_MIN or version == LONG_MAX or version > UINT8_MAX)
{
instance->major_version= instance->minor_version= instance->micro_version= UINT8_MAX;
return memcached_set_error(*instance, MEMCACHED_UNKNOWN_READ_FAILURE, MEMCACHED_AT, memcached_literal_param("strtol() failed to parse micro version"));
*
* Libmemcached library
*
- * Copyright (C) 2011 Data Differential, http://datadifferential.com/
+ * Copyright (C) 2011-2013 Data Differential, http://datadifferential.com/
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
}
else if (strcmp("pid", key) == 0)
{
+ errno= 0;
int64_t temp= strtoll(value, (char **)NULL, 10);
+ if (errno != 0)
+ {
+ return MEMCACHED_FAILURE;
+ }
if (temp <= INT32_MAX and ( sizeof(pid_t) == sizeof(int32_t) ))
{
}
else if (not strcmp("uptime", key))
{
+ errno= 0;
memc_stat->uptime= strtoul(value, (char **)NULL, 10);
+ if (errno != 0)
+ {
+ return MEMCACHED_FAILURE;
+ }
}
else if (not strcmp("time", key))
{
+ errno= 0;
memc_stat->time= strtoul(value, (char **)NULL, 10);
+ if (errno != 0)
+ {
+ return MEMCACHED_FAILURE;
+ }
}
else if (not strcmp("version", key))
{
}
else if (not strcmp("pointer_size", key))
{
+ errno= 0;
memc_stat->pointer_size= strtoul(value, (char **)NULL, 10);
+ if (errno != 0)
+ {
+ return MEMCACHED_FAILURE;
+ }
}
else if (not strcmp("rusage_user", key))
{
for (walk_ptr= (char*)value; (!ispunct(*walk_ptr)); walk_ptr++) {};
*walk_ptr= 0;
walk_ptr++;
+
+ errno= 0;
memc_stat->rusage_user_seconds= strtoul(value, (char **)NULL, 10);
+ if (errno != 0)
+ {
+ return MEMCACHED_FAILURE;
+ }
+
+ errno= 0;
memc_stat->rusage_user_microseconds= strtoul(walk_ptr, (char **)NULL, 10);
+ if (errno != 0)
+ {
+ return MEMCACHED_FAILURE;
+ }
}
else if (not strcmp("rusage_system", key))
{
for (walk_ptr= (char*)value; (!ispunct(*walk_ptr)); walk_ptr++) {};
*walk_ptr= 0;
walk_ptr++;
+
+ errno= 0;
memc_stat->rusage_system_seconds= strtoul(value, (char **)NULL, 10);
+ if (errno != 0)
+ {
+ return MEMCACHED_FAILURE;
+ }
+
+ errno= 0;
memc_stat->rusage_system_microseconds= strtoul(walk_ptr, (char **)NULL, 10);
+ if (errno != 0)
+ {
+ return MEMCACHED_FAILURE;
+ }
}
else if (not strcmp("curr_items", key))
{
+ errno= 0;
memc_stat->curr_items= strtoul(value, (char **)NULL, 10);
+ if (errno != 0)
+ {
+ return MEMCACHED_FAILURE;
+ }
}
else if (not strcmp("total_items", key))
{
+ errno= 0;
memc_stat->total_items= strtoul(value, (char **)NULL, 10);
+ if (errno != 0)
+ {
+ return MEMCACHED_FAILURE;
+ }
}
else if (not strcmp("bytes_read", key))
{
+ errno= 0;
memc_stat->bytes_read= strtoull(value, (char **)NULL, 10);
+ if (errno != 0)
+ {
+ return MEMCACHED_FAILURE;
+ }
}
else if (not strcmp("bytes_written", key))
{
+ errno= 0;
memc_stat->bytes_written= strtoull(value, (char **)NULL, 10);
+ if (errno != 0)
+ {
+ return MEMCACHED_FAILURE;
+ }
}
else if (not strcmp("bytes", key))
{
+ errno= 0;
memc_stat->bytes= strtoull(value, (char **)NULL, 10);
+ if (errno != 0)
+ {
+ return MEMCACHED_FAILURE;
+ }
}
else if (not strcmp("curr_connections", key))
{
+ errno= 0;
memc_stat->curr_connections= strtoull(value, (char **)NULL, 10);
+ if (errno != 0)
+ {
+ return MEMCACHED_FAILURE;
+ }
}
else if (not strcmp("total_connections", key))
{
+ errno= 0;
memc_stat->total_connections= strtoull(value, (char **)NULL, 10);
+ if (errno != 0)
+ {
+ return MEMCACHED_FAILURE;
+ }
}
else if (not strcmp("connection_structures", key))
{
+ errno= 0;
memc_stat->connection_structures= strtoul(value, (char **)NULL, 10);
+ if (errno != 0)
+ {
+ return MEMCACHED_FAILURE;
+ }
}
else if (not strcmp("cmd_get", key))
{
+ errno= 0;
memc_stat->cmd_get= strtoull(value, (char **)NULL, 10);
+ if (errno != 0)
+ {
+ return MEMCACHED_FAILURE;
+ }
}
else if (not strcmp("cmd_set", key))
{
+ errno= 0;
memc_stat->cmd_set= strtoull(value, (char **)NULL, 10);
+ if (errno != 0)
+ {
+ return MEMCACHED_FAILURE;
+ }
}
else if (not strcmp("get_hits", key))
{
+ errno= 0;
memc_stat->get_hits= strtoull(value, (char **)NULL, 10);
+ if (errno != 0)
+ {
+ return MEMCACHED_FAILURE;
+ }
}
else if (not strcmp("get_misses", key))
{
+ errno= 0;
memc_stat->get_misses= strtoull(value, (char **)NULL, 10);
+ if (errno != 0)
+ {
+ return MEMCACHED_FAILURE;
+ }
}
else if (not strcmp("evictions", key))
{
+ errno= 0;
memc_stat->evictions= strtoull(value, (char **)NULL, 10);
+ if (errno != 0)
+ {
+ return MEMCACHED_FAILURE;
+ }
}
else if (not strcmp("limit_maxbytes", key))
{
+ errno= 0;
memc_stat->limit_maxbytes= strtoull(value, (char **)NULL, 10);
+ if (errno != 0)
+ {
+ return MEMCACHED_FAILURE;
+ }
}
else if (not strcmp("threads", key))
{
+ errno= 0;
memc_stat->threads= strtoul(value, (char **)NULL, 10);
+ if (errno != 0)
+ {
+ return MEMCACHED_FAILURE;
+ }
}
- else if (not (strcmp("delete_misses", key) == 0 or /* New stats in the 1.3 beta */
- strcmp("delete_hits", key) == 0 or /* Just swallow them for now.. */
- strcmp("incr_misses", key) == 0 or
- strcmp("incr_hits", key) == 0 or
- strcmp("decr_misses", key) == 0 or
- strcmp("decr_hits", key) == 0 or
- strcmp("cas_misses", key) == 0 or
- strcmp("cas_hits", key) == 0 or
- strcmp("cas_badval", key) == 0 or
- strcmp("cmd_flush", key) == 0 or
- strcmp("accepting_conns", key) == 0 or
- strcmp("listen_disabled_num", key) == 0 or
- strcmp("conn_yields", key) == 0 or
- strcmp("auth_cmds", key) == 0 or
- strcmp("auth_errors", key) == 0 or
- strcmp("reclaimed", key) == 0))
+ else if ((strcmp("delete_misses", key) == 0 or /* New stats in the 1.3 beta */
+ strcmp("delete_hits", key) == 0 or /* Just swallow them for now.. */
+ strcmp("incr_misses", key) == 0 or
+ strcmp("incr_hits", key) == 0 or
+ strcmp("decr_misses", key) == 0 or
+ strcmp("decr_hits", key) == 0 or
+ strcmp("cas_misses", key) == 0 or
+ strcmp("cas_hits", key) == 0 or
+ strcmp("cas_badval", key) == 0 or
+ strcmp("cmd_flush", key) == 0 or
+ strcmp("accepting_conns", key) == 0 or
+ strcmp("listen_disabled_num", key) == 0 or
+ strcmp("conn_yields", key) == 0 or
+ strcmp("auth_cmds", key) == 0 or
+ strcmp("auth_errors", key) == 0 or
+ strcmp("reclaimed", key) == 0) == 0)
{
WATCHPOINT_STRING(key);
/* return MEMCACHED_UNKNOWN_STAT_KEY; */
uint64_t cas;
uint64_t result;
+ errno= 0;
uint64_t delta= strtoull(tokens[2], NULL, 10);
+ if (errno != 0)
+ {
+ return; // Error
+ }
protocol_binary_response_status rval;
if (client->ascii_command == INCR_CMD)
uint32_t timeout= 0;
if (ntokens == 2)
{
+ errno= 0;
timeout= (uint32_t)strtoul(tokens[1], NULL, 10);
+ if (errno != 0)
+ {
+ return; // Error
+ }
}
protocol_binary_response_status rval;
return -1;
}
+ errno= 0;
uint32_t flags= (uint32_t)strtoul(tokens[2], NULL, 10);
+ if (errno != 0)
+ {
+ /* return error */
+ raw_response_handler(client, "CLIENT_ERROR: bad key\r\n");
+ return -1;
+ }
+
uint32_t timeout= (uint32_t)strtoul(tokens[3], NULL, 10);
+ if (errno != 0)
+ {
+ /* return error */
+ raw_response_handler(client, "CLIENT_ERROR: bad key\r\n");
+ return -1;
+ }
+
unsigned long nbytes= strtoul(tokens[4], NULL, 10);
+ if (errno != 0)
+ {
+ /* return error */
+ raw_response_handler(client, "CLIENT_ERROR: bad key\r\n");
+ return -1;
+ }
/* Do we have all data? */
unsigned long need= nbytes + (unsigned long)((*end - start) + 1) + 2; /* \n\r\n */
timeout, &result_cas);
break;
case CAS_CMD:
+ errno= 0;
cas= strtoull(tokens[5], NULL, 10);
+ if (errno != 0)
+ {
+ /* return error */
+ raw_response_handler(client, "CLIENT_ERROR: bad key\r\n");
+ return -1;
+ }
/* FALLTHROUGH */
case REPLACE_CMD:
rval= client->root->callback->interface.v1.replace(client, key,
break;
case OPT_LIBYATL_REPEAT:
+ errno= 0;
opt_repeat= strtoul(optarg, (char **) NULL, 10);
+ if (errno != 0)
+ {
+ Error << "unknown value passed to --repeat: `" << optarg << "`";
+ exit(EXIT_FAILURE);
+ }
+
break;
case OPT_LIBYATL_MATCH_COLLECTION:
srandom((unsigned int)time(NULL));
- if (bool(getenv("YATL_REPEAT")) and (strtoul(getenv("YATL_REPEAT"), (char **) NULL, 10) > 1))
+ errno= 0;
+ if (bool(getenv("YATL_REPEAT")))
{
+ errno= 0;
opt_repeat= strtoul(getenv("YATL_REPEAT"), (char **) NULL, 10);
+ if (errno != 0)
+ {
+ Error << "ENV YATL_REPEAT passed an invalid value: `" << getenv("YATL_REPEAT") << "`";
+ exit(EXIT_FAILURE);
+ }
}
if ((bool(getenv("YATL_QUIET")) and (strcmp(getenv("YATL_QUIET"), "0") == 0)) or opt_quiet)