Skip to content

Commit bb43835

Browse files
alexandruagalxiord
authored andcommitted
jailer: id must be alphanumeric
Added a check to determine whether the id is alphanumeric or not. We return an error in the latter case, just to be on the safe side. Signed-off-by: Alexandru Agache <[email protected]>
1 parent 82f49a0 commit bb43835

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

jailer/src/lib.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ pub enum Error {
3838
Metadata(PathBuf, io::Error),
3939
NotAFile(PathBuf),
4040
NotAFolder(PathBuf),
41+
NotAlphanumeric(String),
4142
OpenDevKvm(sys_util::Error),
4243
OpenDevNetTun(sys_util::Error),
4344
ReadLine(PathBuf, io::Error),
@@ -69,6 +70,13 @@ impl<'a> JailerArgs<'a> {
6970
uid: &str,
7071
gid: &str,
7172
) -> Result<Self> {
73+
// Maybe it's a good idea to restrict the id to alphanumeric strings.
74+
for c in id.chars() {
75+
if !c.is_alphanumeric() {
76+
return Err(Error::NotAlphanumeric(id.to_string()));
77+
}
78+
}
79+
7280
let exec_file_path =
7381
canonicalize(exec_file).map_err(|e| Error::Canonicalize(PathBuf::from(exec_file), e))?;
7482

0 commit comments

Comments
 (0)