Skip to content

Commit 00c7905

Browse files
utkarshkukreticarllerche
authored andcommitted
Use libc::PATH_MAX in NixPath::with_nix_path.
1 parent ad87c3b commit 00c7905

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/lib.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ pub mod unistd;
4343
*
4444
*/
4545

46-
use libc::c_char;
46+
use libc::{c_char, PATH_MAX};
4747
use std::{ptr, result};
4848
use std::ffi::CStr;
4949
use std::path::{Path, PathBuf};
@@ -126,10 +126,9 @@ impl NixPath for [u8] {
126126

127127
fn with_nix_path<T, F>(&self, f: F) -> Result<T>
128128
where F: FnOnce(&CStr) -> T {
129-
// TODO: Extract this size as a const
130-
let mut buf = [0u8; 4096];
129+
let mut buf = [0u8; PATH_MAX as usize];
131130

132-
if self.len() >= 4096 {
131+
if self.len() >= PATH_MAX as usize {
133132
return Err(Error::InvalidPath);
134133
}
135134

0 commit comments

Comments
 (0)