summaryrefslogtreecommitdiffstats
path: root/src/debugserver.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/debugserver.c')
-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
574 574
575 debugserver_error_t result = DEBUGSERVER_E_UNKNOWN_ERROR; 575 debugserver_error_t result = DEBUGSERVER_E_UNKNOWN_ERROR;
576 char *pkt = NULL; 576 char *pkt = NULL;
577 int pkt_len = 0; 577 size_t pkt_len = 0;
578 int i = 0; 578 int i = 0;
579 579
580 /* calculate total length */ 580 /* calculate total length */
581 while (i < argc && argv && argv[i]) { 581 while (i < argc && argv && argv[i]) {
582 char *prefix = NULL; 582 char *prefix = NULL;
583 asprintf(&prefix, ",%d,%d,", (int)strlen(argv[i]) * 2, i); 583 int ret = asprintf(&prefix, ",%zu,%d,", strlen(argv[i]) * 2, i);
584 pkt_len += (int)strlen(prefix) + (int)strlen(argv[i]) * 2; 584 if (ret < 0 || prefix == NULL) {
585 debug_info("asprintf failed, out of memory?");
586 return DEBUGSERVER_E_UNKNOWN_ERROR;
587 }
588 pkt_len += strlen(prefix) + strlen(argv[i]) * 2;
585 free(prefix); 589 free(prefix);
586 i++; 590 i++;
587 } 591 }
@@ -598,10 +602,14 @@ LIBIMOBILEDEVICE_API debugserver_error_t debugserver_client_set_argv(debugserver
598 602
599 char *prefix = NULL; 603 char *prefix = NULL;
600 char *m = NULL; 604 char *m = NULL;
601 int arg_len = strlen(argv[i]); 605 size_t arg_len = strlen(argv[i]);
602 int arg_hexlen = arg_len * 2; 606 size_t arg_hexlen = arg_len * 2;
603 607
604 asprintf(&prefix, ",%d,%d,", arg_hexlen, i); 608 int ret = asprintf(&prefix, ",%zu,%d,", arg_hexlen, i);
609 if (ret < 0 || prefix == NULL) {
610 debug_info("asprintf failed, out of memory?");
611 return DEBUGSERVER_E_UNKNOWN_ERROR;
612 }
605 613
606 m = (char *) malloc(arg_hexlen); 614 m = (char *) malloc(arg_hexlen);
607 char *p = m; 615 char *p = m;