From 00c7905a8a85668d0993420e356a56002ab23905 Mon Sep 17 00:00:00 2001 From: Utkarsh Kukreti Date: Wed, 28 Oct 2015 16:15:11 +0530 Subject: Use `libc::PATH_MAX` in `NixPath::with_nix_path`. --- src/lib.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 7fdcad6d..826ed838 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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(&self, f: F) -> Result 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); } -- cgit v1.2.3