Add support for parsing zero as a configuration setting
MODIFY
frida_mode/include/util.h
frida_mode/include/util.h
#define IGNORED_RETURN(x) (void)!(x)
guint64 util_read_address(char *key);
-
guint64 util_read_num(char *key);
gboolean util_output_enabled(void);
gsize util_rotate(gsize val, gsize shift, gsize size);

MODIFY
frida_mode/src/util.c
frida_mode/src/util.c
guint64 util_read_address(char *key) {
char *value_str = getenv(key);
+ char *end_ptr;
if (value_str == NULL) { return 0; }
@@ -25,8 +26,17 @@ guint64 util_read_address(char *key) {
}
- guint64 value = g_ascii_strtoull(value_str2, NULL, 16);
- if (value == 0) {
+ errno = 0;
+
+ guint64 value = g_ascii_strtoull(value_str2, &end_ptr, 16);
+
+ if (errno != 0) {
+
+ FATAL("Error (%d) during conversion: %s", errno, value_str);
+
+ }
+
+ if (value == 0 && end_ptr == value_str2) {
FATAL("Invalid address failed hex conversion: %s=%s\n", key, value_str2);
@@ -39,6 +49,7 @@ guint64 util_read_address(char *key) {
guint64 util_read_num(char *key) {
char *value_str = getenv(key);
+ char *end_ptr;
if (value_str == NULL) { return 0; }
@@ -53,8 +64,17 @@ guint64 util_read_num(char *key) {
}
+ errno = 0;
+
guint64 value = g_ascii_strtoull(value_str, NULL, 10);
- if (value == 0) {
+
+ if (errno != 0) {
+
+ FATAL("Error (%d) during conversion: %s", errno, value_str);
+
+ }
+
+ if (value == 0 && end_ptr == value_str) {
FATAL("Invalid address failed numeric conversion: %s=%s\n", key, value_str);

Add support for parsing zero as a configuration setting