We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
libc::PATH_MAX
NixPath::with_nix_path
1 parent ad87c3b commit 00c7905Copy full SHA for 00c7905
src/lib.rs
@@ -43,7 +43,7 @@ pub mod unistd;
43
*
44
*/
45
46
-use libc::c_char;
+use libc::{c_char, PATH_MAX};
47
use std::{ptr, result};
48
use std::ffi::CStr;
49
use std::path::{Path, PathBuf};
@@ -126,10 +126,9 @@ impl NixPath for [u8] {
126
127
fn with_nix_path<T, F>(&self, f: F) -> Result<T>
128
where F: FnOnce(&CStr) -> T {
129
- // TODO: Extract this size as a const
130
- let mut buf = [0u8; 4096];
+ let mut buf = [0u8; PATH_MAX as usize];
131
132
- if self.len() >= 4096 {
+ if self.len() >= PATH_MAX as usize {
133
return Err(Error::InvalidPath);
134
}
135
0 commit comments