Issue #491: bus error in resolve_origin()

resolve_origin attempts to insert '\0' into a field from a DL_info
struct, causes BUS error.

Signed-off-by: Nicolas Williams <nico@cryptonector.com>
This commit is contained in:
Arran Cudbard-Bell
2013-12-13 18:49:13 +00:00
committed by Nicolas Williams
parent 38a92f759d
commit f604e424d1

View File

@@ -245,12 +245,16 @@ resolve_origin(const char *di)
p = strrchr(dname, '\\');
if (p == NULL)
#endif
p = strrchr(dname, '/');
if (p)
*p = '\0';
if (asprintf(&path, "%s%s", dname, di) == -1)
return NULL;
p = strrchr(dname, '/');
if (p) {
if (asprintf(&path, "%.*s%s", (int) (p - dname), dname, di) == -1)
return NULL;
} else {
if (asprintf(&path, "%s%s", dname, di) == -1)
return NULL;
}
return path;
#endif
}