Debian Codegraph @

oss-fuzz/encoder_utils.cc

raw symbols SCIP
1 /*
2 Copyright @ 2018 ImageMagick Studio LLC, a non-profit organization
3 dedicated to making software imaging solutions freely available.
4
5 You may not use this file except in compliance with the License. You may
6 obtain a copy of the License at
7
8 https://imagemagick.org/license/
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 static int fuzzEncoderWithStringFileName(const std::string encoder,
18 const uint8_t *data,size_t size,bool (*validate)(const std::string &) = NULL)
19 {
20 std::string
21 fileName;
22
23 if (IsInvalidSize(size))
24 return(0);
25 fileName=std::string(reinterpret_cast<const char*>(data), size);
26 // Can be used to deny specific file names
27 if ((validate != NULL) && (validate(fileName) == false))
28 return(0);
29 try
30 {
31 Magick::Image
32 image;
33
34 image.read(encoder + ":" + fileName);
35 }
36 #if defined(BUILD_MAIN)
37 catch (Magick::Exception &e)
38 {
39 std::cout << "Exception when reading: " << e.what() << std::endl;
40 }
41 #else
42 catch (Magick::Exception)
43 {
44 }
45 #endif
46 return(0);
47 }