From 89dcbf5e1d6f0c391484ebb1112e362ec2b0e2d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vivek=20Das=C2=A0Mohapatra?= <vivek@collabora.co.uk> Date: Fri, 19 May 2017 20:01:05 +0100 Subject: [PATCH] Catch circular symlinks or ones that are too deep as per MAXSYMLINKS --- capsule/capsule-dlmopen.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/capsule/capsule-dlmopen.c b/capsule/capsule-dlmopen.c index 137b065b5..9483b6cdd 100644 --- a/capsule/capsule-dlmopen.c +++ b/capsule/capsule-dlmopen.c @@ -328,7 +328,14 @@ void resolve_symlink_prefixed (ldlibs_t *ldlibs, int i) while( resolve_link(ldlibs->prefix.path, resolved, link_dir) ) { LDLIB_DEBUG( ldlibs, DEBUG_PATH, " resolved to: %s", resolved ); - count++; + + if( ++count > MAXSYMLINKS ) + { + fprintf( stderr, "%s: MAXSYMLINKS (%d) exceeded resolving %s\n", + __PRETTY_FUNCTION__, MAXSYMLINKS, + ldlibs->needed[i].path ); + break; + } } if( count ) -- GitLab