diff options
author | Utkarsh Kukreti <utkarshkukreti@gmail.com> | 2015-10-28 16:15:11 +0530 |
---|---|---|
committer | Carl Lerche <me@carllerche.com> | 2015-11-03 11:04:50 -0800 |
commit | 00c7905a8a85668d0993420e356a56002ab23905 (patch) | |
tree | 6737fa9891c1d0b5eafcf63de43b105eae6a94cd | |
parent | ad87c3bdc99357f66af9260bce1eb6ae2cbfda98 (diff) | |
download | nix-00c7905a8a85668d0993420e356a56002ab23905.zip |
Use `libc::PATH_MAX` in `NixPath::with_nix_path`.
-rw-r--r-- | src/lib.rs | 7 |
1 files changed, 3 insertions, 4 deletions
@@ -43,7 +43,7 @@ pub mod unistd; * */ -use libc::c_char; +use libc::{c_char, PATH_MAX}; use std::{ptr, result}; use std::ffi::CStr; use std::path::{Path, PathBuf}; @@ -126,10 +126,9 @@ impl NixPath for [u8] { fn with_nix_path<T, F>(&self, f: F) -> Result<T> where F: FnOnce(&CStr) -> T { - // TODO: Extract this size as a const - let mut buf = [0u8; 4096]; + let mut buf = [0u8; PATH_MAX as usize]; - if self.len() >= 4096 { + if self.len() >= PATH_MAX as usize { return Err(Error::InvalidPath); } |