From f604e424d1df67f2f3ceebed2b49c0800468a887 Mon Sep 17 00:00:00 2001 From: Arran Cudbard-Bell Date: Fri, 13 Dec 2013 18:49:13 +0000 Subject: [PATCH] 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 --- lib/krb5/plugin.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/krb5/plugin.c b/lib/krb5/plugin.c index 74889406e..f69e9eb67 100644 --- a/lib/krb5/plugin.c +++ b/lib/krb5/plugin.c @@ -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 }