[CRIU] [PATCH] remote: Fix incorrect passing of port option

Radostin Stoyanov rstoyanov1 at gmail.com
Sun Jan 28 19:18:38 MSK 2018


The `port` option for image-cache and image-proxy is converted twice.
- 1st when the argument is provided from the user (in crtools.c)
- 2nd when the value is provided set to `sin_port` (in img-remote.c)
Unfortunately, the 2nd conversion reverses the 1st one.

Example:

	#include <stdio.h>
	#include <arpa/inet.h>
	#include <stdlib.h>

	int main()
	{
	    printf("%d\n", htons(atoi("1234"))); /* 53764 */
	    printf("%d\n", htons(htons(atoi("1234")))); /* 1234 */
	    return 0;
	}
---
 criu/crtools.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/criu/crtools.c b/criu/crtools.c
index 07bb2655..dffae5c8 100644
--- a/criu/crtools.c
+++ b/criu/crtools.c
@@ -719,7 +719,7 @@ int main(int argc, char *argv[], char *envp[])
 			opts.addr = optarg;
 			break;
 		case 1052:
-			opts.port = htons(atoi(optarg));
+			opts.port = atoi(optarg);
 			if (!opts.port)
 				goto bad_arg;
 			break;
-- 
2.14.3



More information about the CRIU mailing list