summaryrefslogtreecommitdiffstats
path: root/vendor/object/src/read/elf/note.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
commitdc0db358abe19481e475e10c32149b53370f1a1c (patch)
treeab8ce99c4b255ce46f99ef402c27916055b899ee /vendor/object/src/read/elf/note.rs
parentReleasing progress-linux version 1.71.1+dfsg1-2~progress7.99u1. (diff)
downloadrustc-dc0db358abe19481e475e10c32149b53370f1a1c.tar.xz
rustc-dc0db358abe19481e475e10c32149b53370f1a1c.zip
Merging upstream version 1.72.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/object/src/read/elf/note.rs')
-rw-r--r--vendor/object/src/read/elf/note.rs23
1 files changed, 13 insertions, 10 deletions
diff --git a/vendor/object/src/read/elf/note.rs b/vendor/object/src/read/elf/note.rs
index fc5aa7753..84d4179de 100644
--- a/vendor/object/src/read/elf/note.rs
+++ b/vendor/object/src/read/elf/note.rs
@@ -113,21 +113,24 @@ impl<'data, Elf: FileHeader> Note<'data, Elf> {
self.header.n_descsz(endian)
}
- /// Return the bytes for the name field following the `NoteHeader`,
- /// excluding any null terminator.
+ /// Return the bytes for the name field following the `NoteHeader`.
///
- /// This field is usually a string including a null terminator
+ /// This field is usually a string including one or more trailing null bytes
/// (but it is not required to be).
///
- /// The length of this field (including any null terminator) is given by
- /// `n_namesz`.
+ /// The length of this field is given by `n_namesz`.
+ pub fn name_bytes(&self) -> &'data [u8] {
+ self.name
+ }
+
+ /// Return the bytes for the name field following the `NoteHeader`,
+ /// excluding all trailing null bytes.
pub fn name(&self) -> &'data [u8] {
- if let Some((last, name)) = self.name.split_last() {
- if *last == 0 {
- return name;
- }
+ let mut name = self.name;
+ while let [rest @ .., 0] = name {
+ name = rest;
}
- self.name
+ name
}
/// Return the bytes for the desc field following the `NoteHeader`.