• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2
3# Copyright (c) 2009 The Chromium Authors. All rights reserved.
4# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6
7# Usage: ./test_malicious_fonts.sh [ttf_or_otf_file_name]
8
9BASE_DIR=~/malicious/
10CHECKER=./validator-checker
11
12if [ ! -x "$CHECKER" ] ; then
13  echo "$CHECKER is not found."
14  exit 1
15fi
16
17if [ $# -eq 0 ] ; then
18  # No font file is specified. Apply this script to all TT/OT files under the
19  # BASE_DIR.
20  if [ ! -d $BASE_DIR ] ; then
21    echo "$BASE_DIR does not exist."
22    exit 1
23  fi
24
25  # Recursively call this script.
26  find $BASE_DIR -type f -name '*tf' -exec "$0" {} \;
27  echo
28  exit 0
29fi
30
31if [ $# -gt 1 ] ; then
32  echo "Usage: $0 [ttf_or_otf_file_name]"
33  exit 1
34fi
35
36# Confirm that the malicious font file does not crash OTS nor OS font renderer.
37base=`basename "$1"`
38"$CHECKER" "$1" > /dev/null 2>&1 || (echo ; echo "\nFAIL: $1 (Run $CHECKER $1 for more information.)")
39echo -n "."
40