~ubuntu-branches/ubuntu/wily/clamav/wily-proposed

« back to all changes in this revision

Viewing changes to libclamav/c++/llvm/lib/Support/GraphWriter.cpp

  • Committer: Package Import Robot
  • Author(s): Scott Kitterman, Sebastian Andrzej Siewior, Andreas Cadhalpun, Scott Kitterman, Javier Fernández-Sanguino
  • Date: 2015-01-28 00:25:13 UTC
  • mfrom: (0.48.14 sid)
  • Revision ID: package-import@ubuntu.com-20150128002513-lil2oi74cooy4lzr
Tags: 0.98.6+dfsg-1
[ Sebastian Andrzej Siewior ]
* update "fix-ssize_t-size_t-off_t-printf-modifier", include of misc.h was
  missing but was pulled in via the systemd patch.
* Don't leak return codes from libmspack to clamav API. (Closes: #774686).

[ Andreas Cadhalpun ]
* Add patch to avoid emitting incremental progress messages when not
  outputting to a terminal. (Closes: #767350)
* Update lintian-overrides for unused-file-paragraph-in-dep5-copyright.
* clamav-base.postinst: always chown /var/log/clamav and /var/lib/clamav
  to clamav:clamav, not only on fresh installations. (Closes: #775400)
* Adapt the clamav-daemon and clamav-freshclam logrotate scripts,
  so that they correctly work under systemd.
* Move the PidFile variable from the clamd/freshclam configuration files
  to the init scripts. This makes the init scripts more robust against
  misconfiguration and avoids error messages with systemd. (Closes: #767353)
* debian/copyright: drop files from Files-Excluded only present in github
  tarballs
* Drop Workaround-a-bug-in-libc-on-Hurd.patch, because hurd got fixed.
  (see #752237)
* debian/rules: Remove useless --with-system-tommath --without-included-ltdl
  configure options.

[ Scott Kitterman ]
* Stop stripping llvm when repacking the tarball as the system llvm on some
  releases is too old to use
* New upstream bugfix release
  - Library shared object revisions.
  - Includes a patch from Sebastian Andrzej Siewior making ClamAV pid files
    compatible with systemd.
  - Fix a heap out of bounds condition with crafted Yoda's crypter files.
    This issue was discovered by Felix Groebert of the Google Security Team.
  - Fix a heap out of bounds condition with crafted mew packer files. This
    issue was discovered by Felix Groebert of the Google Security Team.
  - Fix a heap out of bounds condition with crafted upx packer files. This
    issue was discovered by Kevin Szkudlapski of Quarkslab.
  - Fix a heap out of bounds condition with crafted upack packer files. This
    issue was discovered by Sebastian Andrzej Siewior. CVE-2014-9328.
  - Compensate a crash due to incorrect compiler optimization when handling
    crafted petite packer files. This issue was discovered by Sebastian
    Andrzej Siewior.
* Update lintian override for embedded zlib to match new so version

[ Javier Fernández-Sanguino ]
* Updated Spanish Debconf template translation (Closes: #773563)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//===-- GraphWriter.cpp - Implements GraphWriter support routines ---------===//
 
2
//
 
3
//                     The LLVM Compiler Infrastructure
 
4
//
 
5
// This file is distributed under the University of Illinois Open Source
 
6
// License. See LICENSE.TXT for details.
 
7
//
 
8
//===----------------------------------------------------------------------===//
 
9
//
 
10
// This file implements misc. GraphWriter support routines.
 
11
//
 
12
//===----------------------------------------------------------------------===//
 
13
 
 
14
#include "llvm/Support/GraphWriter.h"
 
15
#include "llvm/System/Path.h"
 
16
#include "llvm/System/Program.h"
 
17
#include "llvm/Config/config.h"
 
18
using namespace llvm;
 
19
 
 
20
std::string llvm::DOT::EscapeString(const std::string &Label) {
 
21
  std::string Str(Label);
 
22
  for (unsigned i = 0; i != Str.length(); ++i)
 
23
  switch (Str[i]) {
 
24
    case '\n':
 
25
      Str.insert(Str.begin()+i, '\\');  // Escape character...
 
26
      ++i;
 
27
      Str[i] = 'n';
 
28
      break;
 
29
    case '\t':
 
30
      Str.insert(Str.begin()+i, ' ');  // Convert to two spaces
 
31
      ++i;
 
32
      Str[i] = ' ';
 
33
      break;
 
34
    case '\\':
 
35
      if (i+1 != Str.length())
 
36
        switch (Str[i+1]) {
 
37
          case 'l': continue; // don't disturb \l
 
38
          case '|': case '{': case '}':
 
39
            Str.erase(Str.begin()+i); continue;
 
40
          default: break;
 
41
        }
 
42
    case '{': case '}':
 
43
    case '<': case '>':
 
44
    case '|': case '"':
 
45
      Str.insert(Str.begin()+i, '\\');  // Escape character...
 
46
      ++i;  // don't infinite loop
 
47
      break;
 
48
  }
 
49
  return Str;
 
50
}
 
51
 
 
52
 
 
53
 
 
54
void llvm::DisplayGraph(const sys::Path &Filename, bool wait,
 
55
                        GraphProgram::Name program) {
 
56
  std::string ErrMsg;
 
57
#if HAVE_GRAPHVIZ
 
58
  sys::Path Graphviz(LLVM_PATH_GRAPHVIZ);
 
59
 
 
60
  std::vector<const char*> args;
 
61
  args.push_back(Graphviz.c_str());
 
62
  args.push_back(Filename.c_str());
 
63
  args.push_back(0);
 
64
  
 
65
  errs() << "Running 'Graphviz' program... ";
 
66
  if (sys::Program::ExecuteAndWait(Graphviz, &args[0],0,0,0,0,&ErrMsg))
 
67
    errs() << "Error viewing graph " << Filename.str() << ": " << ErrMsg
 
68
           << "\n";
 
69
  else
 
70
    Filename.eraseFromDisk();
 
71
 
 
72
#elif (HAVE_GV && (HAVE_DOT || HAVE_FDP || HAVE_NEATO || \
 
73
                   HAVE_TWOPI || HAVE_CIRCO))
 
74
  sys::Path PSFilename = Filename;
 
75
  PSFilename.appendSuffix("ps");
 
76
 
 
77
  sys::Path prog;
 
78
 
 
79
  // Set default grapher
 
80
#if HAVE_CIRCO
 
81
  prog = sys::Path(LLVM_PATH_CIRCO);
 
82
#endif
 
83
#if HAVE_TWOPI
 
84
  prog = sys::Path(LLVM_PATH_TWOPI);
 
85
#endif
 
86
#if HAVE_NEATO
 
87
  prog = sys::Path(LLVM_PATH_NEATO);
 
88
#endif
 
89
#if HAVE_FDP
 
90
  prog = sys::Path(LLVM_PATH_FDP);
 
91
#endif
 
92
#if HAVE_DOT
 
93
  prog = sys::Path(LLVM_PATH_DOT);
 
94
#endif
 
95
 
 
96
  // Find which program the user wants
 
97
#if HAVE_DOT
 
98
  if (program == GraphProgram::DOT)
 
99
    prog = sys::Path(LLVM_PATH_DOT);
 
100
#endif
 
101
#if (HAVE_FDP)
 
102
  if (program == GraphProgram::FDP)
 
103
    prog = sys::Path(LLVM_PATH_FDP);
 
104
#endif
 
105
#if (HAVE_NEATO)
 
106
  if (program == GraphProgram::NEATO)
 
107
    prog = sys::Path(LLVM_PATH_NEATO);
 
108
#endif
 
109
#if (HAVE_TWOPI)
 
110
  if (program == GraphProgram::TWOPI)
 
111
    prog = sys::Path(LLVM_PATH_TWOPI);
 
112
#endif
 
113
#if (HAVE_CIRCO)
 
114
  if (program == GraphProgram::CIRCO)
 
115
    prog = sys::Path(LLVM_PATH_CIRCO);
 
116
#endif
 
117
 
 
118
  std::vector<const char*> args;
 
119
  args.push_back(prog.c_str());
 
120
  args.push_back("-Tps");
 
121
  args.push_back("-Nfontname=Courier");
 
122
  args.push_back("-Gsize=7.5,10");
 
123
  args.push_back(Filename.c_str());
 
124
  args.push_back("-o");
 
125
  args.push_back(PSFilename.c_str());
 
126
  args.push_back(0);
 
127
  
 
128
  errs() << "Running '" << prog.str() << "' program... ";
 
129
 
 
130
  if (sys::Program::ExecuteAndWait(prog, &args[0], 0, 0, 0, 0, &ErrMsg)) {
 
131
     errs() << "Error viewing graph " << Filename.str() << ": '"
 
132
            << ErrMsg << "\n";
 
133
    return;
 
134
  }
 
135
  errs() << " done. \n";
 
136
 
 
137
  sys::Path gv(LLVM_PATH_GV);
 
138
  args.clear();
 
139
  args.push_back(gv.c_str());
 
140
  args.push_back(PSFilename.c_str());
 
141
  args.push_back("--spartan");
 
142
  args.push_back(0);
 
143
  
 
144
  ErrMsg.clear();
 
145
  if (wait) {
 
146
     if (sys::Program::ExecuteAndWait(gv, &args[0],0,0,0,0,&ErrMsg))
 
147
        errs() << "Error viewing graph: " << ErrMsg << "\n";
 
148
     Filename.eraseFromDisk();
 
149
     PSFilename.eraseFromDisk();
 
150
  }
 
151
  else {
 
152
     sys::Program::ExecuteNoWait(gv, &args[0],0,0,0,&ErrMsg);
 
153
     errs() << "Remember to erase graph files: " << Filename.str() << " "
 
154
            << PSFilename.str() << "\n";
 
155
  }
 
156
#elif HAVE_DOTTY
 
157
  sys::Path dotty(LLVM_PATH_DOTTY);
 
158
 
 
159
  std::vector<const char*> args;
 
160
  args.push_back(dotty.c_str());
 
161
  args.push_back(Filename.c_str());
 
162
  args.push_back(0);
 
163
  
 
164
  errs() << "Running 'dotty' program... ";
 
165
  if (sys::Program::ExecuteAndWait(dotty, &args[0],0,0,0,0,&ErrMsg)) {
 
166
     errs() << "Error viewing graph " << Filename.str() << ": "
 
167
            << ErrMsg << "\n";
 
168
  } else {
 
169
// Dotty spawns another app and doesn't wait until it returns
 
170
#if defined (__MINGW32__) || defined (_WINDOWS)
 
171
    return;
 
172
#endif
 
173
    Filename.eraseFromDisk();
 
174
  }
 
175
#endif
 
176
}