Skip to content

Commit

Permalink
signer: Fix a usize vs u32 comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
cdecker committed Nov 9, 2023
1 parent 24db122 commit 059f011
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ jobs:
# inconsistent syntax between shell and powershell.
shell: bash
run: |
cd libs
# Parse out what we just built and upload it to the Github Release™
echo "paths<<EOF" >> "$GITHUB_OUTPUT"
jq --raw-output ".artifacts[]?.path | select( . != null )" dist-manifest.json >> "$GITHUB_OUTPUT"
Expand Down
23 changes: 12 additions & 11 deletions libs/gl-signerproxy/src/passfd.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use libc::{self, c_int, c_uchar, c_void, msghdr};
use std::mem;
use log::trace;
use std::io::{Error, ErrorKind};
use std::mem;
use std::os::unix::io::RawFd;

pub trait SyncFdPassingExt {
Expand Down Expand Up @@ -80,23 +80,24 @@ impl SyncFdPassingExt for RawFd {
0 => Err(Error::new(ErrorKind::UnexpectedEof, "0 bytes read")),
rv if rv < 0 => Err(Error::last_os_error()),
rv if rv == mem::size_of::<c_uchar>() as isize => {
let hdr: *mut libc::cmsghdr =
if msg.msg_controllen >= mem::size_of::<libc::cmsghdr>() as _ {
msg.msg_control as *mut libc::cmsghdr
} else {
return Err(Error::new(
ErrorKind::InvalidData,
"bad control msg (header)",
));
};
let hdr: *mut libc::cmsghdr = if msg.msg_controllen as usize
>= mem::size_of::<libc::cmsghdr>() as usize
{
msg.msg_control as *mut libc::cmsghdr
} else {
return Err(Error::new(
ErrorKind::InvalidData,
"bad control msg (header)",
));
};
if (*hdr).cmsg_level != libc::SOL_SOCKET || (*hdr).cmsg_type != libc::SCM_RIGHTS
{
return Err(Error::new(
ErrorKind::InvalidData,
"bad control msg (level)",
));
}
if msg.msg_controllen
if msg.msg_controllen as usize
!= libc::CMSG_SPACE(mem::size_of::<c_int>() as u32) as usize
{
return Err(Error::new(ErrorKind::InvalidData, "bad control msg (len)"));
Expand Down

0 comments on commit 059f011

Please sign in to comment.