mirror of
				https://github.com/rofl0r/proxychains-ng.git
				synced 2025-11-04 00:56:03 +00:00 
			
		
		
		
	test_getaddrinfo.c: add check for service argument
This commit is contained in:
		@@ -8,13 +8,13 @@
 | 
				
			|||||||
#define   NI_MAXHOST 1025
 | 
					#define   NI_MAXHOST 1025
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int main(void) {
 | 
					static int doit(const char* host, const char* service) {
 | 
				
			||||||
	struct addrinfo *result;
 | 
						struct addrinfo *result;
 | 
				
			||||||
	struct addrinfo *res;
 | 
						struct addrinfo *res;
 | 
				
			||||||
	int error;
 | 
						int error;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* resolve the domain name into a list of addresses */
 | 
						/* resolve the domain name into a list of addresses */
 | 
				
			||||||
	error = getaddrinfo("www.example.com", NULL, NULL, &result);
 | 
						error = getaddrinfo(host, service, NULL, &result);
 | 
				
			||||||
	if (error != 0)
 | 
						if (error != 0)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		fprintf(stderr, "error in getaddrinfo: %s\n", gai_strerror(error));
 | 
							fprintf(stderr, "error in getaddrinfo: %s\n", gai_strerror(error));
 | 
				
			||||||
@@ -39,3 +39,10 @@ int main(void) {
 | 
				
			|||||||
	freeaddrinfo(result);
 | 
						freeaddrinfo(result);
 | 
				
			||||||
	return EXIT_SUCCESS;
 | 
						return EXIT_SUCCESS;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int main(void) {
 | 
				
			||||||
 | 
						int ret;
 | 
				
			||||||
 | 
						ret = doit("www.example.com", NULL);
 | 
				
			||||||
 | 
						ret = doit("www.example.com", "80");
 | 
				
			||||||
 | 
						return ret;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user