From: Matthias Bolte Date: Sun, 3 Apr 2011 09:21:27 +0000 (+0200) Subject: Remove PATH_MAX sized stack allocation from virFileOpenTtyAt X-Git-Tag: v0.9.1~197 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=25f85e493887e45e3849aa7c3914b49b1d9b5eb2;p=thirdparty%2Flibvirt.git Remove PATH_MAX sized stack allocation from virFileOpenTtyAt --- diff --git a/src/util/util.c b/src/util/util.c index 3a0e661be9..526f51c0f6 100644 --- a/src/util/util.c +++ b/src/util/util.c @@ -1902,14 +1902,13 @@ int virFileOpenTtyAt(const char *ptmx, } if (ttyName) { - char tempTtyName[PATH_MAX]; - if (ptsname_r(*ttymaster, tempTtyName, sizeof(tempTtyName)) < 0) - goto cleanup; - - if ((*ttyName = strdup(tempTtyName)) == NULL) { + if (VIR_ALLOC_N(*ttyName, PATH_MAX) < 0) { errno = ENOMEM; goto cleanup; } + + if (ptsname_r(*ttymaster, *ttyName, PATH_MAX) < 0) + goto cleanup; } rc = 0;