From 3c2107bdc221a90b02d3f7118dd96f3496762cd0 Mon Sep 17 00:00:00 2001 From: Steven Danna Date: Mon, 6 Apr 2020 12:54:59 +0000 Subject: unistd: avoid infinite loop caused by reserve_double_buffer_size Functions such as Group::from_anything use reserve_double_buffer_size in a loop, expecting it to return ERANGE if the passed limit is reached. However, the returned vector is passed as pointer to a libc function that writes data into memory and doesn't update the length of the Vec. Because of this, the previous code would never return ERANGE and the calling loops would never exit if they hit a case where the required buffer was larger than the maximum buffer. This fixes the problem by checking the capacity rather than the length. Signed-off-by: Steven Danna --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'CHANGELOG.md') diff --git a/CHANGELOG.md b/CHANGELOG.md index d367ccb2..1f76bfaa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,11 @@ This project adheres to [Semantic Versioning](http://semver.org/). (#[1198](https://github.com/nix-rust/nix/pull/1198)) ### Fixed + +- Fixed a bug in nix::unistd that would result in an infinite loop + when a group or user lookup required a buffer larger than + 16KB. (#[1198](https://github.com/nix-rust/nix/pull/1198)) + ### Removed ## [0.17.0] - 3 February 2020 -- cgit v1.2.3