blob: 456736642de5afe3af1620f4e05633240d081035 [file] [log] [blame]
mtklein65e58242016-01-13 12:57:57 -08001/*
2 * Copyright 2016 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
Mike Kleinc0bd9f92019-04-23 12:05:21 -05008#include "fuzz/Fuzz.h"
9#include "include/codec/SkCodec.h"
10#include "include/core/SkCanvas.h"
11#include "include/core/SkData.h"
12#include "include/core/SkImage.h"
13#include "include/core/SkImageEncoder.h"
14#include "include/core/SkMallocPixelRef.h"
15#include "include/core/SkPaint.h"
16#include "include/core/SkPath.h"
17#include "include/core/SkStream.h"
18#include "include/core/SkSurface.h"
19#include "include/core/SkTextBlob.h"
Kevin Lubickd7255a72019-06-03 11:59:23 -040020#include "src/core/SkFontMgrPriv.h"
Mike Kleinc0bd9f92019-04-23 12:05:21 -050021#include "src/core/SkOSFile.h"
22#include "src/core/SkPicturePriv.h"
23#include "src/core/SkReadBuffer.h"
24#include "src/utils/SkOSPath.h"
Mike Kleinc0bd9f92019-04-23 12:05:21 -050025#include "tools/ToolUtils.h"
Kevin Lubickd7255a72019-06-03 11:59:23 -040026#include "tools/flags/CommandLineFlags.h"
27#include "tools/fonts/TestFontMgr.h"
Hal Canary8a001442018-09-19 11:31:27 -040028
Hal Canary62176db2017-02-27 16:42:03 -050029#include <iostream>
Kevin Lubickacd456a2018-04-24 13:58:16 -040030#include <map>
Kevin Lubickfffa6412018-04-23 16:44:55 -040031#include <regex>
mtkleina1159422016-01-15 05:46:54 -080032#include <signal.h>
Kevin Lubick2541edf2018-01-11 10:27:14 -050033
Mike Klein84836b72019-03-21 11:31:36 -050034static DEFINE_string2(bytes, b, "", "A path to a file or a directory. If a file, the "
35 "contents will be used as the fuzz bytes. If a directory, all files "
36 "in the directory will be used as fuzz bytes for the fuzzer, one at a "
37 "time.");
38static DEFINE_string2(name, n, "", "If --type is 'api', fuzz the API with this name.");
39static DEFINE_string2(dump, d, "", "If not empty, dump 'image*' or 'skp' types as a "
40 "PNG with this name.");
Kevin Lubick9ff5dc92018-01-09 12:47:33 -050041DEFINE_bool2(verbose, v, false, "Print more information while fuzzing.");
Florin Malita7796f002018-06-08 12:25:38 -040042
43// This cannot be inlined in DEFINE_string2 due to interleaved ifdefs
44static constexpr char g_type_message[] = "How to interpret --bytes, one of:\n"
Kevin Lubick0f3d2a62018-10-17 10:24:44 -040045 "android_codec\n"
Florin Malita7796f002018-06-08 12:25:38 -040046 "animated_image_decode\n"
47 "api\n"
48 "color_deserialize\n"
49 "filter_fuzz (equivalent to Chrome's filter_fuzz_stub)\n"
50 "image_decode\n"
Kevin Lubick0f3d2a62018-10-17 10:24:44 -040051 "image_decode_incremental\n"
Florin Malita7796f002018-06-08 12:25:38 -040052 "image_mode\n"
53 "image_scale\n"
Florin Malita80452be2018-06-19 11:27:20 -040054 "json\n"
Florin Malita7796f002018-06-08 12:25:38 -040055 "path_deserialize\n"
Florin Malita7796f002018-06-08 12:25:38 -040056 "region_deserialize\n"
57 "region_set_path\n"
Kevin Lubick2be14d32019-10-21 13:44:48 -040058 "skdescriptor_deserialize\n"
Florin Malita7796f002018-06-08 12:25:38 -040059 "skp\n"
60 "sksl2glsl\n"
Kevin Lubicke9c1ce82019-03-11 11:09:40 -040061 "sksl2metal\n"
Kevin Lubick0f0a7102019-03-18 16:20:55 -040062 "sksl2pipeline\n"
Kevin Lubicke9c1ce82019-03-11 11:09:40 -040063 "sksl2spirv\n"
Florin Malita7796f002018-06-08 12:25:38 -040064#if defined(SK_ENABLE_SKOTTIE)
65 "skottie_json\n"
66#endif
67 "textblob";
68
Mike Klein84836b72019-03-21 11:31:36 -050069static DEFINE_string2(type, t, "", g_type_message);
kjlubickdba57342016-01-21 05:03:28 -080070
Kevin Lubickfffa6412018-04-23 16:44:55 -040071static int fuzz_file(SkString path, SkString type);
kjlubick2a42f482016-02-16 16:14:23 -080072static uint8_t calculate_option(SkData*);
Kevin Lubickfffa6412018-04-23 16:44:55 -040073static SkString try_auto_detect(SkString path, SkString* name);
kjlubickdba57342016-01-21 05:03:28 -080074
Kevin Lubick0f3d2a62018-10-17 10:24:44 -040075static void fuzz_android_codec(sk_sp<SkData>);
76static void fuzz_animated_img(sk_sp<SkData>);
Kevin Lubickfffa6412018-04-23 16:44:55 -040077static void fuzz_api(sk_sp<SkData> bytes, SkString name);
Kevin Lubickf80f1152017-01-06 08:26:56 -050078static void fuzz_color_deserialize(sk_sp<SkData>);
Kevin Lubickd46e85f2017-11-21 17:13:35 -050079static void fuzz_filter_fuzz(sk_sp<SkData>);
Kevin Lubick0f3d2a62018-10-17 10:24:44 -040080static void fuzz_image_decode(sk_sp<SkData>);
81static void fuzz_image_decode_incremental(sk_sp<SkData>);
Kevin Lubick0168e042017-02-14 13:12:37 -050082static void fuzz_img(sk_sp<SkData>, uint8_t, uint8_t);
Florin Malita80452be2018-06-19 11:27:20 -040083static void fuzz_json(sk_sp<SkData>);
Kevin Lubickf04c50a2017-01-06 13:48:19 -050084static void fuzz_path_deserialize(sk_sp<SkData>);
Kevin Lubickedee1ae2017-02-20 17:47:18 -050085static void fuzz_region_deserialize(sk_sp<SkData>);
Kevin Lubick2541edf2018-01-11 10:27:14 -050086static void fuzz_region_set_path(sk_sp<SkData>);
Kevin Lubick2be14d32019-10-21 13:44:48 -040087static void fuzz_skdescriptor_deserialize(sk_sp<SkData>);
Kevin Lubick0168e042017-02-14 13:12:37 -050088static void fuzz_skp(sk_sp<SkData>);
Kevin Lubicke9c1ce82019-03-11 11:09:40 -040089static void fuzz_sksl2glsl(sk_sp<SkData>);
90static void fuzz_sksl2metal(sk_sp<SkData>);
Kevin Lubick0f0a7102019-03-18 16:20:55 -040091static void fuzz_sksl2pipeline(sk_sp<SkData>);
Kevin Lubick2be14d32019-10-21 13:44:48 -040092static void fuzz_sksl2spirv(sk_sp<SkData>);
Kevin Lubickd46e85f2017-11-21 17:13:35 -050093static void fuzz_textblob_deserialize(sk_sp<SkData>);
Herb Derbya839fc02017-03-16 12:30:43 -040094
Kevin Lubickfffa6412018-04-23 16:44:55 -040095static void print_api_names();
96
Florin Malita0b0d93d2018-05-04 15:01:03 -040097#if defined(SK_ENABLE_SKOTTIE)
98static void fuzz_skottie_json(sk_sp<SkData>);
99#endif
100
mtklein65e58242016-01-13 12:57:57 -0800101int main(int argc, char** argv) {
Mike Klein88544fb2019-03-20 10:50:33 -0500102 CommandLineFlags::SetUsage(
103 "Usage: fuzz -t <type> -b <path/to/file> [-n api-to-fuzz]\n"
104 " fuzz -b <path/to/file>\n"
105 "--help lists the valid types. If type is not specified,\n"
106 "fuzz will make a guess based on the name of the file.\n");
107 CommandLineFlags::Parse(argc, argv);
Kevin Lubickd7255a72019-06-03 11:59:23 -0400108 gSkFontMgr_DefaultFactory = &ToolUtils::MakePortableFontMgr;
mtkleinf5e97822016-01-15 06:19:53 -0800109
Kevin Lubickfffa6412018-04-23 16:44:55 -0400110 SkString path = SkString(FLAGS_bytes.isEmpty() ? argv[0] : FLAGS_bytes[0]);
111 SkString type = SkString(FLAGS_type.isEmpty() ? "" : FLAGS_type[0]);
Kevin Lubickf80f1152017-01-06 08:26:56 -0500112
Kevin Lubickfffa6412018-04-23 16:44:55 -0400113 if (!sk_isdir(path.c_str())) {
114 return fuzz_file(path, type);
Kevin Lubickf80f1152017-01-06 08:26:56 -0500115 }
116
Kevin Lubickfffa6412018-04-23 16:44:55 -0400117 SkOSFile::Iter it(path.c_str());
Kevin Lubickf80f1152017-01-06 08:26:56 -0500118 for (SkString file; it.next(&file); ) {
Kevin Lubickfffa6412018-04-23 16:44:55 -0400119 SkString p = SkOSPath::Join(path.c_str(), file.c_str());
Kevin Lubickf80f1152017-01-06 08:26:56 -0500120 SkDebugf("Fuzzing %s\n", p.c_str());
Kevin Lubickfffa6412018-04-23 16:44:55 -0400121 int rv = fuzz_file(p, type);
Kevin Lubickf80f1152017-01-06 08:26:56 -0500122 if (rv != 0) {
123 return rv;
124 }
125 }
126 return 0;
127}
128
Kevin Lubickfffa6412018-04-23 16:44:55 -0400129static int fuzz_file(SkString path, SkString type) {
130 sk_sp<SkData> bytes(SkData::MakeFromFileName(path.c_str()));
kjlubickdba57342016-01-21 05:03:28 -0800131 if (!bytes) {
Kevin Lubickfffa6412018-04-23 16:44:55 -0400132 SkDebugf("Could not read %s\n", path.c_str());
Kevin Lubickf80f1152017-01-06 08:26:56 -0500133 return 1;
kjlubickdba57342016-01-21 05:03:28 -0800134 }
mtklein65e58242016-01-13 12:57:57 -0800135
Kevin Lubickfffa6412018-04-23 16:44:55 -0400136 SkString name = SkString(FLAGS_name.isEmpty() ? "" : FLAGS_name[0]);
137
138 if (type.isEmpty()) {
139 type = try_auto_detect(path, &name);
kjlubickdba57342016-01-21 05:03:28 -0800140 }
Kevin Lubickfffa6412018-04-23 16:44:55 -0400141
142 if (type.isEmpty()) {
143 SkDebugf("Could not autodetect type of %s\n", path.c_str());
144 return 1;
145 }
Kevin Lubick0f3d2a62018-10-17 10:24:44 -0400146 if (type.equals("android_codec")) {
147 fuzz_android_codec(bytes);
148 return 0;
149 }
Kevin Lubickfffa6412018-04-23 16:44:55 -0400150 if (type.equals("animated_image_decode")) {
151 fuzz_animated_img(bytes);
152 return 0;
153 }
154 if (type.equals("api")) {
155 fuzz_api(bytes, name);
156 return 0;
157 }
158 if (type.equals("color_deserialize")) {
159 fuzz_color_deserialize(bytes);
160 return 0;
161 }
Florin Malita80452be2018-06-19 11:27:20 -0400162 if (type.equals("filter_fuzz")) {
163 fuzz_filter_fuzz(bytes);
164 return 0;
165 }
Kevin Lubickfffa6412018-04-23 16:44:55 -0400166 if (type.equals("image_decode")) {
Kevin Lubick0f3d2a62018-10-17 10:24:44 -0400167 fuzz_image_decode(bytes);
168 return 0;
169 }
170 if (type.equals("image_decode_incremental")) {
171 fuzz_image_decode_incremental(bytes);
Kevin Lubickfffa6412018-04-23 16:44:55 -0400172 return 0;
173 }
174 if (type.equals("image_scale")) {
175 uint8_t option = calculate_option(bytes.get());
176 fuzz_img(bytes, option, 0);
177 return 0;
178 }
179 if (type.equals("image_mode")) {
180 uint8_t option = calculate_option(bytes.get());
181 fuzz_img(bytes, 0, option);
182 return 0;
183 }
Florin Malita80452be2018-06-19 11:27:20 -0400184 if (type.equals("json")) {
185 fuzz_json(bytes);
Kevin Lubick9eeede22018-05-03 16:26:10 -0400186 return 0;
187 }
Kevin Lubickfffa6412018-04-23 16:44:55 -0400188 if (type.equals("path_deserialize")) {
189 fuzz_path_deserialize(bytes);
190 return 0;
191 }
192 if (type.equals("region_deserialize")) {
193 fuzz_region_deserialize(bytes);
194 return 0;
195 }
196 if (type.equals("region_set_path")) {
197 fuzz_region_set_path(bytes);
198 return 0;
199 }
200 if (type.equals("pipe")) {
Mike Klein60900b52018-09-21 11:19:45 -0400201 SkDebugf("I would prefer not to.\n");
Kevin Lubickfffa6412018-04-23 16:44:55 -0400202 return 0;
203 }
Kevin Lubick2be14d32019-10-21 13:44:48 -0400204 if (type.equals("skdescriptor_deserialize")) {
205 fuzz_skdescriptor_deserialize(bytes);
206 return 0;
207 }
Florin Malita0b0d93d2018-05-04 15:01:03 -0400208#if defined(SK_ENABLE_SKOTTIE)
Kevin Lubick9eeede22018-05-03 16:26:10 -0400209 if (type.equals("skottie_json")) {
210 fuzz_skottie_json(bytes);
Kevin Lubickfffa6412018-04-23 16:44:55 -0400211 return 0;
212 }
Florin Malita0b0d93d2018-05-04 15:01:03 -0400213#endif
Kevin Lubick9eeede22018-05-03 16:26:10 -0400214 if (type.equals("skp")) {
215 fuzz_skp(bytes);
Kevin Lubickfffa6412018-04-23 16:44:55 -0400216 return 0;
217 }
Kevin Lubickfffa6412018-04-23 16:44:55 -0400218 if (type.equals("sksl2glsl")) {
219 fuzz_sksl2glsl(bytes);
220 return 0;
221 }
Kevin Lubicke9c1ce82019-03-11 11:09:40 -0400222 if (type.equals("sksl2metal")) {
223 fuzz_sksl2metal(bytes);
224 return 0;
225 }
226 if (type.equals("sksl2spirv")) {
227 fuzz_sksl2spirv(bytes);
228 return 0;
229 }
Kevin Lubick0f0a7102019-03-18 16:20:55 -0400230 if (type.equals("sksl2pipeline")) {
231 fuzz_sksl2pipeline(bytes);
232 return 0;
233 }
Kevin Lubicke9c1ce82019-03-11 11:09:40 -0400234 if (type.equals("textblob")) {
235 fuzz_textblob_deserialize(bytes);
236 return 0;
237 }
Kevin Lubick457fa972018-05-29 09:22:06 -0400238 SkDebugf("Unknown type %s\n", type.c_str());
Mike Klein88544fb2019-03-20 10:50:33 -0500239 CommandLineFlags::PrintUsage();
Kevin Lubick9ff5dc92018-01-09 12:47:33 -0500240 return 1;
kjlubickdba57342016-01-21 05:03:28 -0800241}
242
Kevin Lubickfffa6412018-04-23 16:44:55 -0400243static std::map<std::string, std::string> cf_api_map = {
244 {"api_draw_functions", "DrawFunctions"},
245 {"api_gradients", "Gradients"},
246 {"api_image_filter", "ImageFilter"},
247 {"api_mock_gpu_canvas", "MockGPUCanvas"},
248 {"api_null_canvas", "NullCanvas"},
249 {"api_path_measure", "PathMeasure"},
Kevin Lubickde54d7c2018-09-24 08:48:19 -0400250 {"api_pathop", "Pathop"},
Kevin Lubick57507f12018-10-11 09:35:15 -0400251 {"api_polyutils", "PolyUtils"},
Kevin Lubickfffa6412018-04-23 16:44:55 -0400252 {"api_raster_n32_canvas", "RasterN32Canvas"},
Kevin Lubick2be14d32019-10-21 13:44:48 -0400253 {"api_skdescriptor", "SkDescriptor"},
Kevin Lubickfffa6412018-04-23 16:44:55 -0400254 {"jpeg_encoder", "JPEGEncoder"},
255 {"png_encoder", "PNGEncoder"},
Kevin Lubickf84ded22018-10-23 09:28:48 -0400256 {"skia_pathop_fuzzer", "LegacyChromiumPathop"},
Kevin Lubickfffa6412018-04-23 16:44:55 -0400257 {"webp_encoder", "WEBPEncoder"}
258};
259
Kevin Lubick6c560552018-06-20 09:29:23 -0400260// maps clusterfuzz/oss-fuzz -> Skia's name
Kevin Lubickfffa6412018-04-23 16:44:55 -0400261static std::map<std::string, std::string> cf_map = {
Kevin Lubick0f3d2a62018-10-17 10:24:44 -0400262 {"android_codec", "android_codec"},
Kevin Lubickfffa6412018-04-23 16:44:55 -0400263 {"animated_image_decode", "animated_image_decode"},
264 {"image_decode", "image_decode"},
Kevin Lubick0f3d2a62018-10-17 10:24:44 -0400265 {"image_decode_incremental", "image_decode_incremental"},
Kevin Lubickfffa6412018-04-23 16:44:55 -0400266 {"image_filter_deserialize", "filter_fuzz"},
267 {"image_filter_deserialize_width", "filter_fuzz"},
268 {"path_deserialize", "path_deserialize"},
269 {"region_deserialize", "region_deserialize"},
270 {"region_set_path", "region_set_path"},
Kevin Lubick2be14d32019-10-21 13:44:48 -0400271 {"skdescriptor_deserialize", "skdescriptor_deserialize"},
Kevin Lubick6c560552018-06-20 09:29:23 -0400272 {"skjson", "json"},
Kevin Lubicke9c1ce82019-03-11 11:09:40 -0400273 {"sksl2glsl", "sksl2glsl"},
274 {"sksl2metal", "sksl2metal"},
275 {"sksl2spirv", "sksl2spirv"},
Kevin Lubick0f0a7102019-03-18 16:20:55 -0400276 {"sksl2pipeline", "sksl2pipeline"},
Kevin Lubickde54d7c2018-09-24 08:48:19 -0400277#if defined(SK_ENABLE_SKOTTIE)
278 {"skottie_json", "skottie_json"},
279#endif
Kevin Lubickfffa6412018-04-23 16:44:55 -0400280 {"textblob_deserialize", "textblob"}
281};
282
283static SkString try_auto_detect(SkString path, SkString* name) {
284 std::cmatch m;
285 std::regex clusterfuzz("clusterfuzz-testcase(-minimized)?-([a-z0-9_]+)-[\\d]+");
286 std::regex skiafuzzer("(api-)?(\\w+)-[a-f0-9]+");
287
288 if (std::regex_search(path.c_str(), m, clusterfuzz)) {
289 std::string type = m.str(2);
Kevin Lubick6c560552018-06-20 09:29:23 -0400290
291 if (cf_api_map.find(type) != cf_api_map.end()) {
292 *name = SkString(cf_api_map[type].c_str());
293 return SkString("api");
Kevin Lubickfffa6412018-04-23 16:44:55 -0400294 } else {
295 if (cf_map.find(type) != cf_map.end()) {
296 return SkString(cf_map[type].c_str());
297 }
298 }
299 } else if (std::regex_search(path.c_str(), m, skiafuzzer)) {
300 std::string a1 = m.str(1);
301 std::string typeOrName = m.str(2);
302 if (a1.length() > 0) {
303 // it's an api fuzzer
304 *name = SkString(typeOrName.c_str());
305 return SkString("api");
306 } else {
307 return SkString(typeOrName.c_str());
308 }
309 }
310
311 return SkString("");
312}
313
Florin Malita80452be2018-06-19 11:27:20 -0400314void FuzzJSON(sk_sp<SkData> bytes);
Florin Malita7796f002018-06-08 12:25:38 -0400315
Florin Malita80452be2018-06-19 11:27:20 -0400316static void fuzz_json(sk_sp<SkData> bytes){
317 FuzzJSON(bytes);
Florin Malita7796f002018-06-08 12:25:38 -0400318 SkDebugf("[terminated] Done parsing!\n");
319}
Florin Malita7796f002018-06-08 12:25:38 -0400320
Florin Malita0b0d93d2018-05-04 15:01:03 -0400321#if defined(SK_ENABLE_SKOTTIE)
Kevin Lubick9eeede22018-05-03 16:26:10 -0400322void FuzzSkottieJSON(sk_sp<SkData> bytes);
323
324static void fuzz_skottie_json(sk_sp<SkData> bytes){
325 FuzzSkottieJSON(bytes);
326 SkDebugf("[terminated] Done animating!\n");
327}
Florin Malita0b0d93d2018-05-04 15:01:03 -0400328#endif
Kevin Lubick9eeede22018-05-03 16:26:10 -0400329
kjlubick2a42f482016-02-16 16:14:23 -0800330// This adds up the first 1024 bytes and returns it as an 8 bit integer. This allows afl-fuzz to
331// deterministically excercise different paths, or *options* (such as different scaling sizes or
332// different image modes) without needing to introduce a parameter. This way we don't need a
333// image_scale1, image_scale2, image_scale4, etc fuzzer, we can just have a image_scale fuzzer.
334// Clients are expected to transform this number into a different range, e.g. with modulo (%).
335static uint8_t calculate_option(SkData* bytes) {
336 uint8_t total = 0;
337 const uint8_t* data = bytes->bytes();
338 for (size_t i = 0; i < 1024 && i < bytes->size(); i++) {
339 total += data[i];
340 }
341 return total;
342}
343
Kevin Lubickfffa6412018-04-23 16:44:55 -0400344static void print_api_names(){
345 SkDebugf("When using --type api, please choose an API to fuzz with --name/-n:\n");
Hal Canary972eba32018-07-30 17:07:07 -0400346 for (const Fuzzable& fuzzable : sk_tools::Registry<Fuzzable>::Range()) {
Kevin Lubickfffa6412018-04-23 16:44:55 -0400347 SkDebugf("\t%s\n", fuzzable.name);
348 }
349}
350
351static void fuzz_api(sk_sp<SkData> bytes, SkString name) {
Hal Canary972eba32018-07-30 17:07:07 -0400352 for (const Fuzzable& fuzzable : sk_tools::Registry<Fuzzable>::Range()) {
Kevin Lubickfffa6412018-04-23 16:44:55 -0400353 if (name.equals(fuzzable.name)) {
mtkleinf5e97822016-01-15 06:19:53 -0800354 SkDebugf("Fuzzing %s...\n", fuzzable.name);
Kevin Lubick1ac8fd22017-03-01 10:42:45 -0500355 Fuzz fuzz(std::move(bytes));
mtklein65e58242016-01-13 12:57:57 -0800356 fuzzable.fn(&fuzz);
kjlubick47d158e2016-02-01 08:23:50 -0800357 SkDebugf("[terminated] Success!\n");
Kevin Lubickf80f1152017-01-06 08:26:56 -0500358 return;
mtklein65e58242016-01-13 12:57:57 -0800359 }
360 }
mtkleind4387ea2016-01-21 06:13:52 -0800361
Kevin Lubickfffa6412018-04-23 16:44:55 -0400362 print_api_names();
kjlubickdba57342016-01-21 05:03:28 -0800363}
364
365static void dump_png(SkBitmap bitmap) {
366 if (!FLAGS_dump.isEmpty()) {
Mike Kleinea3f0142019-03-20 11:12:10 -0500367 ToolUtils::EncodeImageToFile(FLAGS_dump[0], bitmap, SkEncodedImageFormat::kPNG, 100);
kjlubickdba57342016-01-21 05:03:28 -0800368 SkDebugf("Dumped to %s\n", FLAGS_dump[0]);
369 }
370}
371
Kevin Lubick0f3d2a62018-10-17 10:24:44 -0400372bool FuzzAnimatedImage(sk_sp<SkData> bytes);
Kevin Lubick2416f962018-02-12 08:26:39 -0500373
374static void fuzz_animated_img(sk_sp<SkData> bytes) {
Kevin Lubick0f3d2a62018-10-17 10:24:44 -0400375 if (FuzzAnimatedImage(bytes)) {
376 SkDebugf("[terminated] Success from decoding/drawing animated image!\n");
377 return;
378 }
379 SkDebugf("[terminated] Could not decode or draw animated image.\n");
Kevin Lubick2416f962018-02-12 08:26:39 -0500380}
381
Kevin Lubick0f3d2a62018-10-17 10:24:44 -0400382bool FuzzImageDecode(sk_sp<SkData> bytes);
Kevin Lubick2416f962018-02-12 08:26:39 -0500383
Kevin Lubick0f3d2a62018-10-17 10:24:44 -0400384static void fuzz_image_decode(sk_sp<SkData> bytes) {
385 if (FuzzImageDecode(bytes)) {
386 SkDebugf("[terminated] Success from decoding/drawing image!\n");
387 return;
388 }
389 SkDebugf("[terminated] Could not decode or draw image.\n");
Kevin Lubick2416f962018-02-12 08:26:39 -0500390}
391
Kevin Lubick0f3d2a62018-10-17 10:24:44 -0400392bool FuzzIncrementalImageDecode(sk_sp<SkData> bytes);
393
394static void fuzz_image_decode_incremental(sk_sp<SkData> bytes) {
395 if (FuzzIncrementalImageDecode(bytes)) {
396 SkDebugf("[terminated] Success using incremental decode!\n");
397 return;
398 }
399 SkDebugf("[terminated] Could not incrementally decode and image.\n");
400}
401
402bool FuzzAndroidCodec(sk_sp<SkData> bytes, uint8_t sampleSize);
403
404static void fuzz_android_codec(sk_sp<SkData> bytes) {
405 Fuzz fuzz(bytes);
406 uint8_t sampleSize;
407 fuzz.nextRange(&sampleSize, 1, 64);
408 bytes = SkData::MakeSubset(bytes.get(), 1, bytes->size() - 1);
409 if (FuzzAndroidCodec(bytes, sampleSize)) {
410 SkDebugf("[terminated] Success on Android Codec sampleSize=%u!\n", sampleSize);
411 return;
412 }
413 SkDebugf("[terminated] Could not use Android Codec sampleSize=%u!\n", sampleSize);
414}
415
416// This is a "legacy" fuzzer that likely does too much. It was based off of how
417// DM reads in images. image_decode, image_decode_incremental and android_codec
418// are more targeted fuzzers that do a subset of what this one does.
Kevin Lubickf80f1152017-01-06 08:26:56 -0500419static void fuzz_img(sk_sp<SkData> bytes, uint8_t scale, uint8_t mode) {
kjlubick2a42f482016-02-16 16:14:23 -0800420 // We can scale 1x, 2x, 4x, 8x, 16x
421 scale = scale % 5;
kjlubick5bd98a22016-02-18 06:27:38 -0800422 float fscale = (float)pow(2.0f, scale);
423 SkDebugf("Scaling factor: %f\n", fscale);
kjlubick2a42f482016-02-16 16:14:23 -0800424
Leon Scroggins IIIc5a83662016-12-08 09:07:56 -0500425 // We have 5 different modes of decoding.
426 mode = mode % 5;
kjlubick2a42f482016-02-16 16:14:23 -0800427 SkDebugf("Mode: %d\n", mode);
428
429 // This is mostly copied from DMSrcSink's CodecSrc::draw method.
kjlubick47d158e2016-02-01 08:23:50 -0800430 SkDebugf("Decoding\n");
Mike Reedede7bac2017-07-23 15:30:02 -0400431 std::unique_ptr<SkCodec> codec(SkCodec::MakeFromData(bytes));
kjlubickdba57342016-01-21 05:03:28 -0800432 if (nullptr == codec.get()) {
kjlubick47d158e2016-02-01 08:23:50 -0800433 SkDebugf("[terminated] Couldn't create codec.\n");
Kevin Lubickf80f1152017-01-06 08:26:56 -0500434 return;
kjlubickdba57342016-01-21 05:03:28 -0800435 }
436
437 SkImageInfo decodeInfo = codec->getInfo();
kjlubick2a42f482016-02-16 16:14:23 -0800438 SkISize size = codec->getScaledDimensions(fscale);
Brian Salomon9241a6d2019-10-03 13:26:54 -0400439 decodeInfo = decodeInfo.makeDimensions(size);
kjlubick2a42f482016-02-16 16:14:23 -0800440
kjlubickdba57342016-01-21 05:03:28 -0800441 SkBitmap bitmap;
kjlubickdba57342016-01-21 05:03:28 -0800442 SkCodec::Options options;
443 options.fZeroInitialized = SkCodec::kYes_ZeroInitialized;
444
Mike Reed086a4272017-07-18 10:53:11 -0400445 if (!bitmap.tryAllocPixelsFlags(decodeInfo, SkBitmap::kZeroPixels_AllocFlag)) {
kjlubick47d158e2016-02-01 08:23:50 -0800446 SkDebugf("[terminated] Could not allocate memory. Image might be too large (%d x %d)",
kjlubick2a42f482016-02-16 16:14:23 -0800447 decodeInfo.width(), decodeInfo.height());
Kevin Lubickf80f1152017-01-06 08:26:56 -0500448 return;
kjlubickdba57342016-01-21 05:03:28 -0800449 }
450
kjlubick2a42f482016-02-16 16:14:23 -0800451 switch (mode) {
452 case 0: {//kCodecZeroInit_Mode, kCodec_Mode
Leon Scroggins571b30f2017-07-11 17:35:31 +0000453 switch (codec->getPixels(decodeInfo, bitmap.getPixels(), bitmap.rowBytes(), &options)) {
kjlubick2a42f482016-02-16 16:14:23 -0800454 case SkCodec::kSuccess:
455 SkDebugf("[terminated] Success!\n");
456 break;
457 case SkCodec::kIncompleteInput:
458 SkDebugf("[terminated] Partial Success\n");
459 break;
Leon Scroggins III674a1842017-07-06 12:26:09 -0400460 case SkCodec::kErrorInInput:
461 SkDebugf("[terminated] Partial Success with error\n");
462 break;
kjlubick2a42f482016-02-16 16:14:23 -0800463 case SkCodec::kInvalidConversion:
464 SkDebugf("Incompatible colortype conversion\n");
465 // Crash to allow afl-fuzz to know this was a bug.
466 raise(SIGSEGV);
467 default:
468 SkDebugf("[terminated] Couldn't getPixels.\n");
Kevin Lubickf80f1152017-01-06 08:26:56 -0500469 return;
kjlubick2a42f482016-02-16 16:14:23 -0800470 }
471 break;
472 }
473 case 1: {//kScanline_Mode
Leon Scroggins571b30f2017-07-11 17:35:31 +0000474 if (SkCodec::kSuccess != codec->startScanlineDecode(decodeInfo)) {
475 SkDebugf("[terminated] Could not start scanline decoder\n");
476 return;
477 }
kjlubick2a42f482016-02-16 16:14:23 -0800478
479 void* dst = bitmap.getAddr(0, 0);
480 size_t rowBytes = bitmap.rowBytes();
481 uint32_t height = decodeInfo.height();
Brian Osmanea176c62018-04-06 15:28:23 -0400482 // We do not need to check the return value. On an incomplete
483 // image, memory will be filled with a default value.
484 codec->getScanlines(dst, height, rowBytes);
kjlubick47d158e2016-02-01 08:23:50 -0800485 SkDebugf("[terminated] Success!\n");
kjlubickdba57342016-01-21 05:03:28 -0800486 break;
kjlubick2a42f482016-02-16 16:14:23 -0800487 }
488 case 2: { //kStripe_Mode
489 const int height = decodeInfo.height();
490 // This value is chosen arbitrarily. We exercise more cases by choosing a value that
491 // does not align with image blocks.
492 const int stripeHeight = 37;
493 const int numStripes = (height + stripeHeight - 1) / stripeHeight;
494
495 // Decode odd stripes
Leon Scroggins571b30f2017-07-11 17:35:31 +0000496 if (SkCodec::kSuccess != codec->startScanlineDecode(decodeInfo)
kjlubick2a42f482016-02-16 16:14:23 -0800497 || SkCodec::kTopDown_SkScanlineOrder != codec->getScanlineOrder()) {
498 // This mode was designed to test the new skip scanlines API in libjpeg-turbo.
499 // Jpegs have kTopDown_SkScanlineOrder, and at this time, it is not interesting
500 // to run this test for image types that do not have this scanline ordering.
501 SkDebugf("[terminated] Could not start top-down scanline decoder\n");
Kevin Lubickf80f1152017-01-06 08:26:56 -0500502 return;
kjlubick2a42f482016-02-16 16:14:23 -0800503 }
504
505 for (int i = 0; i < numStripes; i += 2) {
506 // Skip a stripe
507 const int linesToSkip = SkTMin(stripeHeight, height - i * stripeHeight);
508 codec->skipScanlines(linesToSkip);
509
510 // Read a stripe
511 const int startY = (i + 1) * stripeHeight;
512 const int linesToRead = SkTMin(stripeHeight, height - startY);
513 if (linesToRead > 0) {
514 codec->getScanlines(bitmap.getAddr(0, startY), linesToRead, bitmap.rowBytes());
515 }
516 }
517
518 // Decode even stripes
Leon Scroggins571b30f2017-07-11 17:35:31 +0000519 const SkCodec::Result startResult = codec->startScanlineDecode(decodeInfo);
kjlubick2a42f482016-02-16 16:14:23 -0800520 if (SkCodec::kSuccess != startResult) {
521 SkDebugf("[terminated] Failed to restart scanline decoder with same parameters.\n");
Kevin Lubickf80f1152017-01-06 08:26:56 -0500522 return;
kjlubick2a42f482016-02-16 16:14:23 -0800523 }
524 for (int i = 0; i < numStripes; i += 2) {
525 // Read a stripe
526 const int startY = i * stripeHeight;
527 const int linesToRead = SkTMin(stripeHeight, height - startY);
528 codec->getScanlines(bitmap.getAddr(0, startY), linesToRead, bitmap.rowBytes());
529
530 // Skip a stripe
531 const int linesToSkip = SkTMin(stripeHeight, height - (i + 1) * stripeHeight);
532 if (linesToSkip > 0) {
533 codec->skipScanlines(linesToSkip);
534 }
535 }
536 SkDebugf("[terminated] Success!\n");
kjlubickdba57342016-01-21 05:03:28 -0800537 break;
kjlubick2a42f482016-02-16 16:14:23 -0800538 }
539 case 3: { //kSubset_Mode
540 // Arbitrarily choose a divisor.
541 int divisor = 2;
542 // Total width/height of the image.
543 const int W = codec->getInfo().width();
544 const int H = codec->getInfo().height();
545 if (divisor > W || divisor > H) {
546 SkDebugf("[terminated] Cannot codec subset: divisor %d is too big "
547 "with dimensions (%d x %d)\n", divisor, W, H);
Kevin Lubickf80f1152017-01-06 08:26:56 -0500548 return;
kjlubick2a42f482016-02-16 16:14:23 -0800549 }
550 // subset dimensions
551 // SkWebpCodec, the only one that supports subsets, requires even top/left boundaries.
552 const int w = SkAlign2(W / divisor);
553 const int h = SkAlign2(H / divisor);
554 SkIRect subset;
555 SkCodec::Options opts;
556 opts.fSubset = &subset;
557 SkBitmap subsetBm;
558 // We will reuse pixel memory from bitmap.
559 void* pixels = bitmap.getPixels();
560 // Keep track of left and top (for drawing subsetBm into canvas). We could use
561 // fscale * x and fscale * y, but we want integers such that the next subset will start
562 // where the last one ended. So we'll add decodeInfo.width() and height().
563 int left = 0;
564 for (int x = 0; x < W; x += w) {
565 int top = 0;
566 for (int y = 0; y < H; y+= h) {
567 // Do not make the subset go off the edge of the image.
568 const int preScaleW = SkTMin(w, W - x);
569 const int preScaleH = SkTMin(h, H - y);
570 subset.setXYWH(x, y, preScaleW, preScaleH);
571 // And fscale
572 // FIXME: Should we have a version of getScaledDimensions that takes a subset
573 // into account?
574 decodeInfo = decodeInfo.makeWH(
575 SkTMax(1, SkScalarRoundToInt(preScaleW * fscale)),
576 SkTMax(1, SkScalarRoundToInt(preScaleH * fscale)));
577 size_t rowBytes = decodeInfo.minRowBytes();
Leon Scroggins571b30f2017-07-11 17:35:31 +0000578 if (!subsetBm.installPixels(decodeInfo, pixels, rowBytes)) {
kjlubick2a42f482016-02-16 16:14:23 -0800579 SkDebugf("[terminated] Could not install pixels.\n");
Kevin Lubickf80f1152017-01-06 08:26:56 -0500580 return;
kjlubick2a42f482016-02-16 16:14:23 -0800581 }
582 const SkCodec::Result result = codec->getPixels(decodeInfo, pixels, rowBytes,
Leon Scroggins571b30f2017-07-11 17:35:31 +0000583 &opts);
kjlubick2a42f482016-02-16 16:14:23 -0800584 switch (result) {
585 case SkCodec::kSuccess:
586 case SkCodec::kIncompleteInput:
Leon Scroggins III674a1842017-07-06 12:26:09 -0400587 case SkCodec::kErrorInInput:
kjlubick2a42f482016-02-16 16:14:23 -0800588 SkDebugf("okay\n");
589 break;
590 case SkCodec::kInvalidConversion:
591 if (0 == (x|y)) {
592 // First subset is okay to return unimplemented.
593 SkDebugf("[terminated] Incompatible colortype conversion\n");
Kevin Lubickf80f1152017-01-06 08:26:56 -0500594 return;
kjlubick2a42f482016-02-16 16:14:23 -0800595 }
596 // If the first subset succeeded, a later one should not fail.
597 // fall through to failure
598 case SkCodec::kUnimplemented:
599 if (0 == (x|y)) {
600 // First subset is okay to return unimplemented.
601 SkDebugf("[terminated] subset codec not supported\n");
Kevin Lubickf80f1152017-01-06 08:26:56 -0500602 return;
kjlubick2a42f482016-02-16 16:14:23 -0800603 }
604 // If the first subset succeeded, why would a later one fail?
605 // fall through to failure
606 default:
607 SkDebugf("[terminated] subset codec failed to decode (%d, %d, %d, %d) "
608 "with dimensions (%d x %d)\t error %d\n",
609 x, y, decodeInfo.width(), decodeInfo.height(),
610 W, H, result);
Kevin Lubickf80f1152017-01-06 08:26:56 -0500611 return;
kjlubick2a42f482016-02-16 16:14:23 -0800612 }
613 // translate by the scaled height.
614 top += decodeInfo.height();
615 }
616 // translate by the scaled width.
617 left += decodeInfo.width();
618 }
619 SkDebugf("[terminated] Success!\n");
620 break;
621 }
Leon Scroggins IIIc5a83662016-12-08 09:07:56 -0500622 case 4: { //kAnimated_Mode
623 std::vector<SkCodec::FrameInfo> frameInfos = codec->getFrameInfo();
624 if (frameInfos.size() == 0) {
625 SkDebugf("[terminated] Not an animated image\n");
626 break;
627 }
628
629 for (size_t i = 0; i < frameInfos.size(); i++) {
630 options.fFrameIndex = i;
631 auto result = codec->startIncrementalDecode(decodeInfo, bitmap.getPixels(),
632 bitmap.rowBytes(), &options);
633 if (SkCodec::kSuccess != result) {
634 SkDebugf("[terminated] failed to start incremental decode "
635 "in frame %d with error %d\n", i, result);
Kevin Lubickf80f1152017-01-06 08:26:56 -0500636 return;
Leon Scroggins IIIc5a83662016-12-08 09:07:56 -0500637 }
638
639 result = codec->incrementalDecode();
Leon Scroggins III674a1842017-07-06 12:26:09 -0400640 if (result == SkCodec::kIncompleteInput || result == SkCodec::kErrorInInput) {
Leon Scroggins IIIc5a83662016-12-08 09:07:56 -0500641 SkDebugf("okay\n");
642 // Frames beyond this one will not decode.
643 break;
644 }
645 if (result == SkCodec::kSuccess) {
646 SkDebugf("okay - decoded frame %d\n", i);
647 } else {
648 SkDebugf("[terminated] incremental decode failed with "
649 "error %d\n", result);
Kevin Lubickf80f1152017-01-06 08:26:56 -0500650 return;
Leon Scroggins IIIc5a83662016-12-08 09:07:56 -0500651 }
652 }
653 SkDebugf("[terminated] Success!\n");
654 break;
655 }
kjlubickdba57342016-01-21 05:03:28 -0800656 default:
kjlubick2a42f482016-02-16 16:14:23 -0800657 SkDebugf("[terminated] Mode not implemented yet\n");
kjlubickdba57342016-01-21 05:03:28 -0800658 }
659
660 dump_png(bitmap);
mtklein65e58242016-01-13 12:57:57 -0800661}
662
Kevin Lubickf80f1152017-01-06 08:26:56 -0500663static void fuzz_skp(sk_sp<SkData> bytes) {
Kevin Lubick09757b22017-12-12 12:52:39 -0500664 SkReadBuffer buf(bytes->data(), bytes->size());
kjlubickdba57342016-01-21 05:03:28 -0800665 SkDebugf("Decoding\n");
Cary Clarkefd99cc2018-06-11 16:25:43 -0400666 sk_sp<SkPicture> pic(SkPicturePriv::MakeFromBuffer(buf));
kjlubickdba57342016-01-21 05:03:28 -0800667 if (!pic) {
kjlubick47d158e2016-02-01 08:23:50 -0800668 SkDebugf("[terminated] Couldn't decode as a picture.\n");
Kevin Lubickf80f1152017-01-06 08:26:56 -0500669 return;
kjlubickdba57342016-01-21 05:03:28 -0800670 }
671 SkDebugf("Rendering\n");
672 SkBitmap bitmap;
673 if (!FLAGS_dump.isEmpty()) {
674 SkIRect size = pic->cullRect().roundOut();
675 bitmap.allocN32Pixels(size.width(), size.height());
676 }
677 SkCanvas canvas(bitmap);
678 canvas.drawPicture(pic);
kjlubick47d158e2016-02-01 08:23:50 -0800679 SkDebugf("[terminated] Success! Decoded and rendered an SkPicture!\n");
kjlubickdba57342016-01-21 05:03:28 -0800680 dump_png(bitmap);
kjlubickdba57342016-01-21 05:03:28 -0800681}
mtklein65e58242016-01-13 12:57:57 -0800682
Kevin Lubickf80f1152017-01-06 08:26:56 -0500683static void fuzz_color_deserialize(sk_sp<SkData> bytes) {
kjlubick3e3c1a52016-06-23 10:49:27 -0700684 sk_sp<SkColorSpace> space(SkColorSpace::Deserialize(bytes->data(), bytes->size()));
685 if (!space) {
686 SkDebugf("[terminated] Couldn't deserialize Colorspace.\n");
Kevin Lubickf80f1152017-01-06 08:26:56 -0500687 return;
kjlubick3e3c1a52016-06-23 10:49:27 -0700688 }
689 SkDebugf("[terminated] Success! deserialized Colorspace.\n");
kjlubick3e3c1a52016-06-23 10:49:27 -0700690}
691
Kevin Lubickf034d112018-02-08 14:31:24 -0500692void FuzzPathDeserialize(SkReadBuffer& buf);
Kevin Lubickc9d28292017-11-09 08:12:56 -0500693
Kevin Lubickf034d112018-02-08 14:31:24 -0500694static void fuzz_path_deserialize(sk_sp<SkData> bytes) {
695 SkReadBuffer buf(bytes->data(), bytes->size());
696 FuzzPathDeserialize(buf);
697 SkDebugf("[terminated] path_deserialize didn't crash!\n");
Kevin Lubickf04c50a2017-01-06 13:48:19 -0500698}
699
Kevin Lubick2541edf2018-01-11 10:27:14 -0500700bool FuzzRegionDeserialize(sk_sp<SkData> bytes);
701
Kevin Lubickedee1ae2017-02-20 17:47:18 -0500702static void fuzz_region_deserialize(sk_sp<SkData> bytes) {
Kevin Lubick2541edf2018-01-11 10:27:14 -0500703 if (!FuzzRegionDeserialize(bytes)) {
Kevin Lubickedee1ae2017-02-20 17:47:18 -0500704 SkDebugf("[terminated] Couldn't initialize SkRegion.\n");
705 return;
706 }
Kevin Lubickedee1ae2017-02-20 17:47:18 -0500707 SkDebugf("[terminated] Success! Initialized SkRegion.\n");
708}
709
Kevin Lubickf034d112018-02-08 14:31:24 -0500710void FuzzTextBlobDeserialize(SkReadBuffer& buf);
711
Kevin Lubickd46e85f2017-11-21 17:13:35 -0500712static void fuzz_textblob_deserialize(sk_sp<SkData> bytes) {
Mike Reedfadbfcd2017-12-06 16:09:20 -0500713 SkReadBuffer buf(bytes->data(), bytes->size());
Kevin Lubickf034d112018-02-08 14:31:24 -0500714 FuzzTextBlobDeserialize(buf);
715 SkDebugf("[terminated] textblob didn't crash!\n");
Kevin Lubickd46e85f2017-11-21 17:13:35 -0500716}
717
Kevin Lubick2541edf2018-01-11 10:27:14 -0500718void FuzzRegionSetPath(Fuzz* fuzz);
719
720static void fuzz_region_set_path(sk_sp<SkData> bytes) {
721 Fuzz fuzz(bytes);
722 FuzzRegionSetPath(&fuzz);
723 SkDebugf("[terminated] region_set_path didn't crash!\n");
724}
725
Kevin Lubickf034d112018-02-08 14:31:24 -0500726void FuzzImageFilterDeserialize(sk_sp<SkData> bytes);
727
Herb Derbya839fc02017-03-16 12:30:43 -0400728static void fuzz_filter_fuzz(sk_sp<SkData> bytes) {
Kevin Lubickf034d112018-02-08 14:31:24 -0500729 FuzzImageFilterDeserialize(bytes);
730 SkDebugf("[terminated] filter_fuzz didn't crash!\n");
Herb Derbya839fc02017-03-16 12:30:43 -0400731}
732
Kevin Lubicke9c1ce82019-03-11 11:09:40 -0400733bool FuzzSKSL2GLSL(sk_sp<SkData> bytes);
734
Kevin Lubickf80f1152017-01-06 08:26:56 -0500735static void fuzz_sksl2glsl(sk_sp<SkData> bytes) {
Kevin Lubicke9c1ce82019-03-11 11:09:40 -0400736 if (FuzzSKSL2GLSL(bytes)) {
737 SkDebugf("[terminated] Success! Compiled input to GLSL.\n");
738 } else {
739 SkDebugf("[terminated] Could not compile input to GLSL.\n");
kjlubicke7195772016-10-18 10:06:24 -0700740 }
kjlubicke7195772016-10-18 10:06:24 -0700741}
Kevin Lubicke9c1ce82019-03-11 11:09:40 -0400742
743bool FuzzSKSL2SPIRV(sk_sp<SkData> bytes);
744
745static void fuzz_sksl2spirv(sk_sp<SkData> bytes) {
746 if (FuzzSKSL2SPIRV(bytes)) {
747 SkDebugf("[terminated] Success! Compiled input to SPIRV.\n");
748 } else {
749 SkDebugf("[terminated] Could not compile input to SPIRV.\n");
750 }
751}
752
753bool FuzzSKSL2Metal(sk_sp<SkData> bytes);
754
755static void fuzz_sksl2metal(sk_sp<SkData> bytes) {
756 if (FuzzSKSL2Metal(bytes)) {
Kevin Lubick39cbe462019-03-11 15:38:00 -0400757 SkDebugf("[terminated] Success! Compiled input to Metal.\n");
Kevin Lubicke9c1ce82019-03-11 11:09:40 -0400758 } else {
Kevin Lubick39cbe462019-03-11 15:38:00 -0400759 SkDebugf("[terminated] Could not compile input to Metal.\n");
Kevin Lubicke9c1ce82019-03-11 11:09:40 -0400760 }
761}
Kevin Lubick0f0a7102019-03-18 16:20:55 -0400762
763bool FuzzSKSL2Pipeline(sk_sp<SkData> bytes);
764
765static void fuzz_sksl2pipeline(sk_sp<SkData> bytes) {
766 if (FuzzSKSL2Pipeline(bytes)) {
767 SkDebugf("[terminated] Success! Compiled input to pipeline stage.\n");
768 } else {
769 SkDebugf("[terminated] Could not compile input to pipeline stage.\n");
770 }
771}
Kevin Lubick2be14d32019-10-21 13:44:48 -0400772
773void FuzzSkDescriptorDeserialize(sk_sp<SkData> bytes);
774
775static void fuzz_skdescriptor_deserialize(sk_sp<SkData> bytes) {
776 FuzzSkDescriptorDeserialize(bytes);
777 SkDebugf("[terminated] Did not crash while deserializing an SkDescriptor.\n");
778}
779