]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
Remove PATH_MAX sized stack allocation from virFileOpenTtyAt
authorMatthias Bolte <matthias.bolte@googlemail.com>
Sun, 3 Apr 2011 09:21:27 +0000 (11:21 +0200)
committerMatthias Bolte <matthias.bolte@googlemail.com>
Tue, 5 Apr 2011 07:10:32 +0000 (09:10 +0200)
src/util/util.c

index 3a0e661be9d706cc0c8f9693ba0323debb7704e2..526f51c0f696193fc7600a8b7a6546f979daba54 100644 (file)
@@ -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;