From: Eric Blake Date: Wed, 22 Jun 2011 20:03:30 +0000 (-0600) Subject: tests: avoid PATH_MAX-sized array X-Git-Tag: v0.9.3-rc1~70 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ca8b4cec6d427a181789aca0ead51c9b8f1b179c;p=thirdparty%2Flibvirt.git tests: avoid PATH_MAX-sized array See previous patch for why this is good... * src/test/test_driver.c (struct _testConn, testOpenFromFile) (testClose): Manage path dynamically. --- diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 6c8b9cf801..18f6a52c14 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -77,7 +77,7 @@ typedef struct _testCell *testCellPtr; struct _testConn { virMutex lock; - char path[PATH_MAX]; + char *path; int nextDomID; virCapsPtr caps; virNodeInfo nodeInfo; @@ -790,9 +790,8 @@ static int testOpenFromFile(virConnectPtr conn, privconn->nextDomID = 1; privconn->numCells = 0; - if (virStrcpyStatic(privconn->path, file) == NULL) { - testError(VIR_ERR_INTERNAL_ERROR, - _("Path %s too big for destination"), file); + if ((privconn->path = strdup(file)) == NULL) { + virReportOOMError(); goto error; } memmove(&privconn->nodeInfo, &defaultNodeInfo, sizeof(defaultNodeInfo)); @@ -1090,6 +1089,7 @@ static int testOpenFromFile(virConnectPtr conn, virNetworkObjListFree(&privconn->networks); virInterfaceObjListFree(&privconn->ifaces); virStoragePoolObjListFree(&privconn->pools); + VIR_FREE(privconn->path); testDriverUnlock(privconn); VIR_FREE(privconn); conn->privateData = NULL; @@ -1161,6 +1161,7 @@ static int testClose(virConnectPtr conn) virInterfaceObjListFree(&privconn->ifaces); virStoragePoolObjListFree(&privconn->pools); virDomainEventStateFree(privconn->domainEventState); + VIR_FREE(privconn->path); testDriverUnlock(privconn); virMutexDestroy(&privconn->lock);