about summary refs log tree commit diff
path: root/pkgs/games
diff options
context:
space:
mode:
authorAnders Kaseorg <andersk@mit.edu>2020-01-01 16:29:34 -0800
committerFrederik Rietdijk <freddyrietdijk@fridh.nl>2020-01-15 09:47:03 +0100
commit3cd8ce3bce1e3d89b21caa0d3ad458193f5179ba (patch)
tree7a1f1889004dce271903d69dce5c1f5a2cf92b07 /pkgs/games
parent2e5051e2235f93829f0d6531ace21e87f2a486a4 (diff)
downloadnixlib-3cd8ce3bce1e3d89b21caa0d3ad458193f5179ba.tar
nixlib-3cd8ce3bce1e3d89b21caa0d3ad458193f5179ba.tar.gz
nixlib-3cd8ce3bce1e3d89b21caa0d3ad458193f5179ba.tar.bz2
nixlib-3cd8ce3bce1e3d89b21caa0d3ad458193f5179ba.tar.lz
nixlib-3cd8ce3bce1e3d89b21caa0d3ad458193f5179ba.tar.xz
nixlib-3cd8ce3bce1e3d89b21caa0d3ad458193f5179ba.tar.zst
nixlib-3cd8ce3bce1e3d89b21caa0d3ad458193f5179ba.zip
treewide: Fix unsafe concatenation of $LD_LIBRARY_PATH
Naive concatenation of $LD_LIBRARY_PATH can result in an empty
colon-delimited segment; this tells glibc to load libraries from the
current directory, which is definitely wrong, and may be a security
vulnerability if the current directory is untrusted.  (See #67234, for
example.)  Fix this throughout the tree.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
Diffstat (limited to 'pkgs/games')
-rw-r--r--pkgs/games/dwarf-fortress/dfhack/default.nix2
-rw-r--r--pkgs/games/dwarf-fortress/wrapper/dfhack.in2
-rw-r--r--pkgs/games/steam/chrootenv.nix4
3 files changed, 4 insertions, 4 deletions
diff --git a/pkgs/games/dwarf-fortress/dfhack/default.nix b/pkgs/games/dwarf-fortress/dfhack/default.nix
index 544fa26b21cc..5706337dffd7 100644
--- a/pkgs/games/dwarf-fortress/dfhack/default.nix
+++ b/pkgs/games/dwarf-fortress/dfhack/default.nix
@@ -109,7 +109,7 @@ let
     '';
 
     preBuild = ''
-      export LD_LIBRARY_PATH="$PWD/depends/protobuf:$LD_LIBRARY_PATH"
+      export LD_LIBRARY_PATH="$PWD/depends/protobuf''${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH"
     '';
 
     cmakeFlags = [ "-DDFHACK_BUILD_ARCH=${arch}" "-DDOWNLOAD_RUBY=OFF" ]
diff --git a/pkgs/games/dwarf-fortress/wrapper/dfhack.in b/pkgs/games/dwarf-fortress/wrapper/dfhack.in
index 4cf884ebed2c..026b33ab87bf 100644
--- a/pkgs/games/dwarf-fortress/wrapper/dfhack.in
+++ b/pkgs/games/dwarf-fortress/wrapper/dfhack.in
@@ -7,5 +7,5 @@ for i in dfhack.init-example dfhack-config/default hack/* stonesense/*; do
 done
 
 cd "$DF_DIR"
-LD_LIBRARY_PATH="$env_dir/hack/libs:$env_dir/hack:$LD_LIBRARY_PATH" \
+LD_LIBRARY_PATH="$env_dir/hack/libs:$env_dir/hack${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH" \
   LD_PRELOAD="$env_dir/hack/libdfhack.so:$LD_PRELOAD" exec $env_dir/libs/Dwarf_Fortress "$@"
diff --git a/pkgs/games/steam/chrootenv.nix b/pkgs/games/steam/chrootenv.nix
index 9229f4fbc93e..4245704575c4 100644
--- a/pkgs/games/steam/chrootenv.nix
+++ b/pkgs/games/steam/chrootenv.nix
@@ -53,7 +53,7 @@ let
       echo "$runtime_paths"
       exit 0
     fi
-    export LD_LIBRARY_PATH="$runtime_paths:$LD_LIBRARY_PATH"
+    export LD_LIBRARY_PATH="$runtime_paths''${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH"
     exec "$@"
   '';
 
@@ -260,7 +260,7 @@ in buildFHSUserEnv rec {
         exit 1
       fi
       shift
-      ${lib.optionalString (!nativeOnly) "export LD_LIBRARY_PATH=/lib32:/lib64:${lib.concatStringsSep ":" ldPath}:$LD_LIBRARY_PATH"}
+      ${lib.optionalString (!nativeOnly) "export LD_LIBRARY_PATH=/lib32:/lib64:${lib.concatStringsSep ":" ldPath}\${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH"}
       exec -- "$run" "$@"
     '';
   };