#include "util-debug.h"
#include "util-spm-bm.h"
#include "util-print.h"
+#include "util-byte.h"
#include "util-unittest.h"
#include "util-unittest-helper.h"
SCLogDebug("k='%s', v='%s'", k, v);
if (strcmp(k, "retval") == 0) {
- if (atoi(v) == 1)
+ int val;
+ if (StringParseInt32(&val, 10, 0, (const char *)v) < 0) {
+ SCLogError(SC_ERR_INVALID_VALUE, "Invalid value "
+ "for \"retval\" from LUA return table: '%s'", v);
+ ret = 0;
+ }
+ else if (val == 1) {
ret = 1;
+ }
} else {
/* set flow var? */
}
SCLogDebug("k='%s', v='%s'", k, v);
if (strcmp(k, "retval") == 0) {
- if (atoi(v) == 1)
+ int val;
+ if (StringParseInt32(&val, 10, 0,
+ (const char *)v) < 0) {
+ SCLogError(SC_ERR_INVALID_VALUE, "Invalid value "
+ "for \"retval\" from LUA return table: '%s'", v);
+ ret = 0;
+ }
+ else if (val == 1) {
ret = 1;
+ }
} else {
/* set flow var? */
}
SCLogDebug("k='%s', v='%s'", k, v);
if (strcmp(k, "retval") == 0) {
- if (atoi(v) == 1)
+ int val;
+ if (StringParseInt32(&val, 10, 0,
+ (const char *)v) < 0) {
+ SCLogError(SC_ERR_INVALID_VALUE, "Invalid value "
+ "for \"retval\" from LUA return table: '%s'", v);
+ ret = 0;
+ }
+ else if (val == 1) {
ret = 1;
+ }
} else {
/* set flow var? */
}
#include "util-unittest.h"
#include "util-unittest-helper.h"
+#include "util-byte.h"
#include "app-layer-nfs-tcp.h"
#include "rust.h"
}
/* set the first value */
- dd->lo = atoi(value1); //TODO
-
+ if (StringParseUint32(&dd->lo, 10, 0, (const char *)value1) < 0) {
+ SCLogError(SC_ERR_INVALID_ARGUMENT, "Invalid first value: \"%s\"", value1);
+ goto error;
+ }
/* set the second value if specified */
if (strlen(value2) > 0) {
if (!(dd->mode == PROCEDURE_RA)) {
goto error;
}
- //
- dd->hi = atoi(value2); // TODO
+ if (StringParseUint32(&dd->hi, 10, 0, (const char *)value2) < 0) {
+ SCLogError(SC_ERR_INVALID_ARGUMENT, "Invalid second value: \"%s\"", value2);
+ goto error;
+ }
if (dd->hi <= dd->lo) {
SCLogError(SC_ERR_INVALID_ARGUMENT,
#include "util-unittest.h"
#include "util-unittest-helper.h"
+#include "util-byte.h"
#include "app-layer-nfs-tcp.h"
#include "rust.h"
}
/* set the first value */
- dd->lo = atoi(value1); //TODO
-
+ if (StringParseUint32(&dd->lo, 10, 0, (const char *)value1) < 0) {
+ SCLogError(SC_ERR_INVALID_ARGUMENT, "Invalid first value: \"%s\"", value1);
+ goto error;
+ }
/* set the second value if specified */
if (strlen(value2) > 0) {
if (!(dd->mode == PROCEDURE_RA)) {
goto error;
}
- //
- dd->hi = atoi(value2); // TODO
-
+ if (StringParseUint32(&dd->hi, 10, 0, (const char *)value2) < 0) {
+ SCLogError(SC_ERR_INVALID_ARGUMENT, "Invalid second value: \"%s\"", value2);
+ goto error;
+ }
if (dd->hi <= dd->lo) {
SCLogError(SC_ERR_INVALID_ARGUMENT,
"Second value in range must not be smaller than the first");
#include "detect-stream_size.h"
#include "stream-tcp-private.h"
#include "util-debug.h"
+#include "util-byte.h"
/**
* \brief Regex for parsing our flow options
}
/* set the value */
- sd->ssize = (uint32_t)atoi(value);
-
+ if (StringParseUint32(&sd->ssize, 10, 0, (const char *)value) < 0) {
+ SCLogError(SC_ERR_INVALID_VALUE, "Invalid value for stream size: %s", value);
+ goto error;
+ }
/* inspect our options and set the flags */
if (strcmp(arg, "server") == 0) {
sd->flags |= STREAM_SIZE_SERVER;
#include "detect.h"
#include "detect-parse.h"
#include "detect-engine-prefilter-common.h"
+#include "util-byte.h"
#include "detect-tcpmss.h"
goto error;
tcpmssd->mode = DETECT_TCPMSS_LT;
- tcpmssd->arg1 = (uint16_t) atoi(arg3);
-
+ if (StringParseUint16(&tcpmssd->arg1, 10, 0, (const char *)arg3) < 0) {
+ SCLogError(SC_ERR_INVALID_SIGNATURE, "Invalid first arg: %s", arg3);
+ goto error;
+ }
SCLogDebug("tcpmss is %"PRIu16"",tcpmssd->arg1);
if (strlen(arg1) > 0)
goto error;
goto error;
tcpmssd->mode = DETECT_TCPMSS_GT;
- tcpmssd->arg1 = (uint16_t) atoi(arg3);
-
+ if (StringParseUint16(&tcpmssd->arg1, 10, 0, (const char *)arg3) < 0) {
+ SCLogError(SC_ERR_INVALID_SIGNATURE, "Invalid first arg: %s", arg3);
+ goto error;
+ }
SCLogDebug("tcpmss is %"PRIu16"",tcpmssd->arg1);
if (strlen(arg1) > 0)
goto error;
goto error;
tcpmssd->mode = DETECT_TCPMSS_RA;
- tcpmssd->arg1 = (uint16_t) atoi(arg1);
-
- tcpmssd->arg2 = (uint16_t) atoi(arg3);
+ if (StringParseUint16(&tcpmssd->arg1, 10, 0, (const char *)arg1) < 0) {
+ SCLogError(SC_ERR_INVALID_SIGNATURE, "Invalid first arg: %s", arg1);
+ goto error;
+ }
+ if (StringParseUint16(&tcpmssd->arg2, 10, 0, (const char *)arg3) < 0) {
+ SCLogError(SC_ERR_INVALID_SIGNATURE, "Invalid second arg: %s", arg3);
+ goto error;
+ }
SCLogDebug("tcpmss is %"PRIu16" to %"PRIu16"",tcpmssd->arg1, tcpmssd->arg2);
if (tcpmssd->arg1 >= tcpmssd->arg2) {
SCLogError(SC_ERR_INVALID_SIGNATURE, "Invalid tcpmss range. ");
(arg1 == NULL ||strlen(arg1) == 0))
goto error;
- tcpmssd->arg1 = (uint16_t) atoi(arg1);
+ if (StringParseUint16(&tcpmssd->arg1, 10, 0, (const char *)arg1) < 0) {
+ SCLogError(SC_ERR_INVALID_SIGNATURE, "Invalid first arg: %s", arg1);
+ goto error;
+ }
break;
}
} else {
(arg1 == NULL ||strlen(arg1) == 0))
goto error;
- tcpmssd->arg1 = (uint16_t) atoi(arg1);
+ if (StringParseUint16(&tcpmssd->arg1, 10, 0, (const char *)arg1) < 0) {
+ SCLogError(SC_ERR_INVALID_SIGNATURE, "Invalid first arg: %s", arg1);
+ goto error;
+ }
}
SCFree(arg1);
#include "suricata-common.h"
#include "util-unittest.h"
+#include "util-byte.h"
#include "detect-parse.h"
#include "detect-engine.h"
if (unlikely(templated == NULL))
return NULL;
- templated->arg1 = (uint8_t)atoi(arg1);
- templated->arg2 = (uint8_t)atoi(arg2);
-
+ if (ByteExtractStringUint8(&templated->arg1, 10, 0, (const char *)arg1) < 0) {
+ SCFree(templated);
+ return NULL;
+ }
+ if (ByteExtractStringUint8(&templated->arg2, 10, 0, (const char *)arg2) < 0) {
+ SCFree(templated);
+ return NULL;
+ }
return templated;
}
*/
#include "suricata-common.h"
+#include "util-byte.h"
#include "detect.h"
#include "detect-parse.h"
goto error;
template2d->mode = DETECT_TEMPLATE2_LT;
- template2d->arg1 = (uint8_t) atoi(arg3);
-
+ if (StringParseUint8(&template2d->arg1, 10, 0, (const char *)arg3) < 0) {
+ SCLogError(SC_ERR_INVALID_SIGNATURE, "Invalid first arg:"
+ " \"%s\"", arg3);
+ goto error;
+ }
SCLogDebug("template2 is %"PRIu8"",template2d->arg1);
if (strlen(arg1) > 0)
goto error;
goto error;
template2d->mode = DETECT_TEMPLATE2_GT;
- template2d->arg1 = (uint8_t) atoi(arg3);
-
+ if (StringParseUint8(&template2d->arg1, 10, 0, (const char *)arg3) < 0) {
+ SCLogError(SC_ERR_INVALID_SIGNATURE, "Invalid first arg:"
+ " \"%s\"", arg3);
+ goto error;
+ }
SCLogDebug("template2 is %"PRIu8"",template2d->arg1);
if (strlen(arg1) > 0)
goto error;
goto error;
template2d->mode = DETECT_TEMPLATE2_RA;
- template2d->arg1 = (uint8_t) atoi(arg1);
-
- template2d->arg2 = (uint8_t) atoi(arg3);
+ if (StringParseUint8(&template2d->arg1, 10, 0, (const char *)arg1) < 0) {
+ SCLogError(SC_ERR_INVALID_SIGNATURE, "Invalid first arg:"
+ " \"%s\"", arg1);
+ goto error;
+ }
+ if (StringParseUint8(&template2d->arg2, 10, 0, (const char *)arg3) < 0) {
+ SCLogError(SC_ERR_INVALID_SIGNATURE, "Invalid second arg:"
+ " \"%s\"", arg3);
+ goto error;
+ }
SCLogDebug("template2 is %"PRIu8" to %"PRIu8"",template2d->arg1, template2d->arg2);
if (template2d->arg1 >= template2d->arg2) {
SCLogError(SC_ERR_INVALID_SIGNATURE, "Invalid template2 range. ");
(arg1 == NULL ||strlen(arg1) == 0))
goto error;
- template2d->arg1 = (uint8_t) atoi(arg1);
+ if (StringParseUint8(&template2d->arg1, 10, 0, (const char *)arg1) < 0) {
+ SCLogError(SC_ERR_INVALID_SIGNATURE, "Invalid first arg:"
+ " \"%s\"", arg1);
+ goto error;
+ }
break;
}
} else {
(arg1 == NULL ||strlen(arg1) == 0))
goto error;
- template2d->arg1 = (uint8_t) atoi(arg1);
+ if (StringParseUint8(&template2d->arg1, 10, 0, (const char *)arg1) < 0) {
+ SCLogError(SC_ERR_INVALID_SIGNATURE, "Invalid first arg:"
+ " \"%s\"", arg1);
+ goto error;
+ }
}
SCFree(arg1);
#include "detect-ttl.h"
#include "util-debug.h"
+#include "util-byte.h"
/**
* \brief Regex for parsing our ttl options
return NULL;
mode = DETECT_TTL_LT;
- ttl1 = atoi(arg3);
-
+ if (StringParseInt32(&ttl1, 10, 0, (const char *)arg3) < 0) {
+ SCLogError(SC_ERR_INVALID_SIGNATURE, "Invalid first ttl "
+ "value: \"%s\"", arg3);
+ return NULL;
+ }
SCLogDebug("ttl is %d",ttl1);
if (strlen(arg1) > 0)
return NULL;
return NULL;
mode = DETECT_TTL_GT;
- ttl1 = atoi(arg3);
-
+ if (StringParseInt32(&ttl1, 10, 0, (const char *)arg3) < 0) {
+ SCLogError(SC_ERR_INVALID_SIGNATURE, "Invalid first ttl "
+ "value: \"%s\"", arg3);
+ return NULL;
+ }
SCLogDebug("ttl is %d",ttl1);
if (strlen(arg1) > 0)
return NULL;
return NULL;
mode = DETECT_TTL_RA;
- ttl1 = atoi(arg1);
- ttl2 = atoi(arg3);
+ if (StringParseInt32(&ttl1, 10, 0, (const char *)arg1) < 0) {
+ SCLogError(SC_ERR_INVALID_SIGNATURE, "Invalid first ttl "
+ "value: \"%s\"", arg1);
+ return NULL;
+ }
+ if (StringParseInt32(&ttl2, 10, 0, (const char *)arg3) < 0) {
+ SCLogError(SC_ERR_INVALID_SIGNATURE, "Invalid second ttl "
+ "value: \"%s\"", arg3);
+ return NULL;
+ }
SCLogDebug("ttl is %d to %d",ttl1, ttl2);
if (ttl1 >= ttl2) {
SCLogError(SC_ERR_INVALID_SIGNATURE, "invalid ttl range");
(strlen(arg3) > 0) ||
(strlen(arg1) == 0))
return NULL;
-
- ttl1 = atoi(arg1);
+ if (StringParseInt32(&ttl1, 10, 0, (const char *)arg1) < 0) {
+ SCLogError(SC_ERR_INVALID_SIGNATURE, "Invalid first ttl "
+ "value: \"%s\"", arg1);
+ return NULL;
+ }
break;
}
} else {
if ((strlen(arg3) > 0) ||
(strlen(arg1) == 0))
return NULL;
-
- ttl1 = atoi(arg1);
+ if (StringParseInt32(&ttl1, 10, 0, (const char *)arg1) < 0) {
+ SCLogError(SC_ERR_INVALID_SIGNATURE, "Invalid first ttl "
+ "value: \"%s\"", arg1);
+ return NULL;
+ }
}
if (ttl1 < 0 || ttl1 > UCHAR_MAX ||