Skip to content

Commit 5c06a13

Browse files
authored
fix portability on 32-bit platforms + add a check for this in CI (#1172)
1 parent 19778b1 commit 5c06a13

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

.github/workflows/ci.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,36 @@ jobs:
302302
- name: Run tests
303303
run: sudo -ubuilder cargo test --workspace --all-targets --release
304304

305+
build-and-test-32bit:
306+
runs-on: ubuntu-latest
307+
308+
steps:
309+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
310+
311+
- name: Add 32-bit target
312+
run: |
313+
rustup target add i686-unknown-linux-gnu
314+
315+
- name: Install dependencies
316+
run: |
317+
sudo dpkg --add-architecture i386
318+
sudo apt update
319+
sudo apt install libpam0g-dev:i386 gcc-multilib
320+
321+
- name: Rust Cache
322+
uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6
323+
with:
324+
shared-key: "stable-32bit"
325+
326+
- name: Register rust problem matcher
327+
run: echo "::add-matcher::.github/problem-matchers/rust.json"
328+
329+
- name: Build
330+
run: cargo build --target i686-unknown-linux-gnu --workspace --all-targets --release
331+
332+
- name: Run tests
333+
run: cargo test --target i686-unknown-linux-gnu --workspace --all-targets --release
334+
305335
miri:
306336
needs: build-and-test
307337
runs-on: ubuntu-latest

src/pam/rpassword.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,13 @@ impl io::Read for TimeoutRead<'_> {
219219
};
220220

221221
// SAFETY: pollfd is initialized and its length matches
222-
cerr(unsafe { libc::poll(pollfd.as_mut_ptr(), pollfd.len() as u64, timeout) })?;
222+
cerr(unsafe {
223+
libc::poll(
224+
pollfd.as_mut_ptr(),
225+
pollfd.len().try_into().unwrap(),
226+
timeout,
227+
)
228+
})?;
223229

224230
// There may yet be data waiting to be read even if POLLHUP is set.
225231
if pollfd[0].revents & (pollmask | libc::POLLHUP) > 0 {

0 commit comments

Comments
 (0)