- multiple graphs to file output causes a segfault #1845
- lefty PTY functionality relies on file descriptor implementation details #1823
- buffer overflow in fdpgen
+- Crashes by VRML output when current directory is not writable #793
## [2.44.1] - 2020-06-29
/* for late_double() */
#include <cgraph/agxbuf.h>
+#include <cgraph/cgraph.h>
#include <common/utils.h>
/* for wind() */
MinZ = z;
if (shapeOf(n) != SH_POINT) {
PNGfile = nodefile(job->output_filename, n);
+ if (PNGfile == NULL) {
+ agerrorf("failed to open file for writing PNG node image\n");
+ }
width = (ND_lw(n) + ND_rw(n)) * Scale + 2 * NODE_PAD;
height = (ND_ht(n) ) * Scale + 2 * NODE_PAD;
static void vrml_end_node(GVJ_t *job)
{
if (im) {
- gdImagePng(im, PNGfile);
- fclose(PNGfile);
+ if (PNGfile != NULL) {
+ gdImagePng(im, PNGfile);
+ fclose(PNGfile);
+ }
gdImageDestroy(im);
im = NULL;
}
import subprocess
import os
import re
+import stat
import tempfile
# The terminology used in rtest.py is a little inconsistent. At the
assert any(r'hello \\\" world' in l for l in ldraw), \
'unexpected ldraw contents'
+def test_793():
+ '''
+ Graphviz should not crash when using VRML output with a non-writable current
+ directory
+ https://gitlab.com/graphviz/graphviz/-/issues/793
+ '''
+
+ # create a non-writable directory
+ with tempfile.TemporaryDirectory() as tmp:
+ os.chmod(tmp, os.stat(tmp).st_mode & ~stat.S_IWRITE)
+
+ # ask the VRML back end to handle a simple graph, using the above as the
+ # current working directory
+ p = subprocess.Popen(['dot', '-Tvrml', '-o', os.devnull], cwd=tmp)
+ p.communicate('digraph { a -> b; }')
+
+ # Graphviz should not have caused a segfault
+ assert p.returncode != -signal.SIGSEGV, 'Graphviz segfaulted'
+
def test_1314():
'''
test that a large font size that produces an overflow in Pango is rejected