1 /*
2 # Copyright 2021 Google LLC
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 #
16 ################################################################################
17 */
18
19 #include <stdint.h>
20 #include <stdlib.h>
21 #include <string.h>
22
23 #include "util.h"
24
LLVMFuzzerTestOneInput(const uint8_t * data,size_t size)25 int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
26 char *nstr = (char *)malloc(size + 1);
27 if (nstr == NULL) {
28 return 0;
29 }
30 memcpy(nstr, data, size);
31 nstr[size] = '\0';
32
33 guchar *tmp = NULL;
34 gsize retlen;
35
36 if (size % 2 == 0 && strlen(nstr) > 0) {
37 tmp = purple_base16_decode(nstr, &retlen);
38 if (tmp != NULL) {
39 g_free(tmp);
40 }
41 }
42
43 tmp = NULL;
44 tmp = purple_quotedp_decode(nstr, &retlen);
45 if (tmp != NULL) {
46 g_free(tmp);
47 }
48
49 char *tmp2 = NULL;
50 tmp2 = purple_mime_decode_field(nstr);
51 if (tmp2 != NULL) {
52 free(tmp2);
53 }
54
55 purple_str_to_time(nstr, TRUE, NULL, NULL, NULL);
56
57 gchar *xhtml = NULL;
58 gchar *plaintext = NULL;
59 purple_markup_html_to_xhtml(nstr, &xhtml, &plaintext);
60
61 if (xhtml != NULL) {
62 g_free(xhtml);
63 }
64
65 if (plaintext != NULL) {
66 g_free(plaintext);
67 }
68
69 char *tmp3 = purple_markup_strip_html(nstr);
70 if (tmp3 != NULL) {
71 free(tmp3);
72 }
73
74 purple_markup_is_rtl(nstr);
75
76 free(nstr);
77 return 0;
78 }
79