Coverage Report

Created: 2026-06-02 06:36

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/php-src/sapi/fuzzer/fuzzer-exif.c
Line
Count
Source
1
/*
2
   +----------------------------------------------------------------------+
3
   | Copyright © The PHP Group and Contributors.                          |
4
   +----------------------------------------------------------------------+
5
   | This source file is subject to the Modified BSD License that is      |
6
   | bundled with this package in the file LICENSE, and is available      |
7
   | through the World Wide Web at <https://www.php.net/license/>.        |
8
   |                                                                      |
9
   | SPDX-License-Identifier: BSD-3-Clause                                |
10
   +----------------------------------------------------------------------+
11
   | Authors: Stanislav Malyshev <stas@php.net>                           |
12
   +----------------------------------------------------------------------+
13
 */
14
15
#include "fuzzer.h"
16
17
#include "Zend/zend.h"
18
#include <main/php_config.h>
19
#include "main/php_main.h"
20
#include "ext/standard/php_var.h"
21
22
#include <stdio.h>
23
#include <stdint.h>
24
#include <stdlib.h>
25
#include <sys/types.h>
26
#include <sys/stat.h>
27
#include <fcntl.h>
28
29
#include "fuzzer-sapi.h"
30
31
1.99k
int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
32
1.99k
#ifdef HAVE_EXIF
33
1.99k
  php_stream *stream;
34
1.99k
  zval stream_zv;
35
36
1.99k
  if (Size > 256 * 1024) {
37
    /* Large inputs have a large impact on fuzzer performance,
38
     * but are unlikely to be necessary to reach new codepaths. */
39
1
    return 0;
40
1
  }
41
42
1.99k
  if (fuzzer_request_startup() == FAILURE) {
43
0
    return 0;
44
0
  }
45
46
1.99k
  stream = php_stream_memory_create(TEMP_STREAM_DEFAULT);
47
1.99k
  php_stream_write(stream, (const char *) Data, Size);
48
1.99k
  php_stream_to_zval(stream, &stream_zv);
49
50
1.99k
  fuzzer_call_php_func_zval("exif_read_data", 1, &stream_zv);
51
52
1.99k
  zval_ptr_dtor(&stream_zv);
53
54
  /* cleanup */
55
1.99k
  php_request_shutdown(NULL);
56
57
1.99k
  return 0;
58
#else
59
  fprintf(stderr, "\n\nERROR:\nPHP built without EXIF, recompile with --enable-exif to use this fuzzer\n");
60
  exit(1);
61
#endif
62
1.99k
}
63
64
2
int LLVMFuzzerInitialize(int *argc, char ***argv) {
65
2
  fuzzer_init_php(NULL);
66
67
  /* fuzzer_shutdown_php(); */
68
2
  return 0;
69
2
}
70