summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/debugserver.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/debugserver.c b/src/debugserver.c
index b6a8b62..46686f6 100644
--- a/src/debugserver.c
+++ b/src/debugserver.c
@@ -574,14 +574,18 @@ LIBIMOBILEDEVICE_API debugserver_error_t debugserver_client_set_argv(debugserver
debugserver_error_t result = DEBUGSERVER_E_UNKNOWN_ERROR;
char *pkt = NULL;
- int pkt_len = 0;
+ size_t pkt_len = 0;
int i = 0;
/* calculate total length */
while (i < argc && argv && argv[i]) {
char *prefix = NULL;
- asprintf(&prefix, ",%d,%d,", (int)strlen(argv[i]) * 2, i);
- pkt_len += (int)strlen(prefix) + (int)strlen(argv[i]) * 2;
+ int ret = asprintf(&prefix, ",%zu,%d,", strlen(argv[i]) * 2, i);
+ if (ret < 0 || prefix == NULL) {
+ debug_info("asprintf failed, out of memory?");
+ return DEBUGSERVER_E_UNKNOWN_ERROR;
+ }
+ pkt_len += strlen(prefix) + strlen(argv[i]) * 2;
free(prefix);
i++;
}
@@ -598,10 +602,14 @@ LIBIMOBILEDEVICE_API debugserver_error_t debugserver_client_set_argv(debugserver
char *prefix = NULL;
char *m = NULL;
- int arg_len = strlen(argv[i]);
- int arg_hexlen = arg_len * 2;
+ size_t arg_len = strlen(argv[i]);
+ size_t arg_hexlen = arg_len * 2;
- asprintf(&prefix, ",%d,%d,", arg_hexlen, i);
+ int ret = asprintf(&prefix, ",%zu,%d,", arg_hexlen, i);
+ if (ret < 0 || prefix == NULL) {
+ debug_info("asprintf failed, out of memory?");
+ return DEBUGSERVER_E_UNKNOWN_ERROR;
+ }
m = (char *) malloc(arg_hexlen);
char *p = m;