| 
									
										
										
										
											2020-06-19 11:54:41 +01:00
										 |  |  |  | #include "fuzz.h"
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-30 11:10:51 +01:00
										 |  |  |  | static void | 
					
						
							|  |  |  |  | test_with_flags (const gchar *data, | 
					
						
							|  |  |  |  |                  GUriFlags    flags) | 
					
						
							| 
									
										
										
										
											2020-06-19 11:54:41 +01:00
										 |  |  |  | { | 
					
						
							|  |  |  |  |   GUri *uri = NULL; | 
					
						
							|  |  |  |  |   gchar *uri_string = NULL; | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-30 11:10:51 +01:00
										 |  |  |  |   uri = g_uri_parse (data, flags, NULL); | 
					
						
							| 
									
										
										
										
											2020-06-29 11:52:40 +01:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-19 11:54:41 +01:00
										 |  |  |  |   if (uri == NULL) | 
					
						
							| 
									
										
										
										
											2020-06-30 11:10:51 +01:00
										 |  |  |  |     return; | 
					
						
							| 
									
										
										
										
											2020-06-19 11:54:41 +01:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |   uri_string = g_uri_to_string (uri); | 
					
						
							|  |  |  |  |   g_uri_unref (uri); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |   if (uri_string == NULL) | 
					
						
							| 
									
										
										
										
											2020-06-30 11:10:51 +01:00
										 |  |  |  |     return; | 
					
						
							| 
									
										
										
										
											2020-06-19 11:54:41 +01:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |   g_free (uri_string); | 
					
						
							| 
									
										
										
										
											2020-06-30 11:10:51 +01:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | int | 
					
						
							|  |  |  |  | LLVMFuzzerTestOneInput (const unsigned char *data, size_t size) | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |   unsigned char *nul_terminated_data = NULL; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |   fuzz_set_logging_func (); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |   /* ignore @size (g_uri_parse() doesn’t support it); ensure @data is nul-terminated */ | 
					
						
							|  |  |  |  |   nul_terminated_data = (unsigned char *) g_strndup ((const gchar *) data, size); | 
					
						
							|  |  |  |  |   test_with_flags ((const gchar *) nul_terminated_data, G_URI_FLAGS_NONE); | 
					
						
							|  |  |  |  |   test_with_flags ((const gchar *) nul_terminated_data, G_URI_FLAGS_PARSE_STRICT); | 
					
						
							|  |  |  |  |   g_free (nul_terminated_data); | 
					
						
							| 
									
										
										
										
											2020-06-19 11:54:41 +01:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |   return 0; | 
					
						
							|  |  |  |  | } |