]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
fileio: minor tweak to executable_is_script()
authorLennart Poettering <lennart@poettering.net>
Sat, 30 Dec 2017 14:44:29 +0000 (15:44 +0100)
committerLennart Poettering <lennart@poettering.net>
Thu, 4 Jan 2018 12:28:24 +0000 (13:28 +0100)
If read_line() returns ENOBFUS this means the line was overly long. When
we use this for checking whether an executable is a script, then this
shouldn't be propagated as-is, but simply as "this is not a script".

src/basic/fileio.c

index 7d71a3e985378677a2945aaf15f8b9624ec1776c..430851cc8caaa1307dcdb62f20eda76b07b0bccb 100644 (file)
@@ -926,14 +926,16 @@ int write_env_file(const char *fname, char **l) {
 }
 
 int executable_is_script(const char *path, char **interpreter) {
-        int r;
         _cleanup_free_ char *line = NULL;
-        int len;
+        size_t len;
         char *ans;
+        int r;
 
         assert(path);
 
         r = read_one_line_file(path, &line);
+        if (r == -ENOBUFS) /* First line overly long? if so, then it's not a script */
+                return 0;
         if (r < 0)
                 return r;