do not use default when dynamic linker fails to open existing path file
authorRich Felker <dalias@aerifal.cx>
Mon, 9 Sep 2013 17:39:08 +0000 (13:39 -0400)
committerRich Felker <dalias@aerifal.cx>
Mon, 9 Sep 2013 17:39:08 +0000 (13:39 -0400)
if fopen fails for a reason other than ENOENT, we must assume the
intent is that the path file be used. failure may be due to
misconfiguration or intentional resource-exhaustion attack (against
suid programs), in which case falling back to loading libraries from
an unintended path could be dangerous.

src/ldso/dynlink.c

index 6d3d08edee8c2fc4df01f265ea81555e4342b55d..a89e74320048162048b77fa50ad0e17ab263ccd7 100644 (file)
@@ -614,6 +614,8 @@ static struct dso *load_library(const char *name, struct dso *needed_by)
                                                sys_path = "";
                                        }
                                        fclose(f);
+                               } else if (errno != ENOENT) {
+                                       sys_path = "";
                                }
                        }
                        if (!sys_path) sys_path = "/lib:/usr/local/lib:/usr/lib";