Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jhoward/macos xattr get all chars #1095

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Features

Bug Fixes
---------
* Avoid truncating final character when macOS getXAttr reads a non-null-terminated xattr, e.g. an xattr created using `xattr -w user.sample 1 myfile.txt`.
* Avoid including null termination as part of macOS setXAttr.
* [#1091](https://github.com/java-native-access/jna/issues/1091): Check target number to be greater than zero, before calling `Structure#toArray` in `c.s.j.p.win32.Netapi32Util` - [@trevormagg](https://github.com/trevormaggs), [@matthiasblaesing](https://github.com/matthiasblaesing).

Release 5.3.1
Expand Down
4 changes: 2 additions & 2 deletions contrib/platform/src/com/sun/jna/platform/mac/XAttrUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ public static String getXAttr(String path, String name) {
if (valueLength < 0)
return null;

return decodeString(valueBuffer.getByteBuffer(0, valueLength - 1));
return decodeString(valueBuffer.getByteBuffer(0, valueLength));
}

public static int setXAttr(String path, String name, String value) {
Memory valueBuffer = encodeString(value);
return XAttr.INSTANCE.setxattr(path, name, valueBuffer, valueBuffer.size(), 0, 0);
return XAttr.INSTANCE.setxattr(path, name, valueBuffer, valueBuffer.size() - 1, 0, 0);
}

public static int removeXAttr(String path, String name) {
Expand Down