Commit df9ee49
committed
fix: freebsd's xattr returns the number of bytes read
On linux, the xattr API returns the ERANGE if the result doesn't fit. On
FreeBSD, it returns the number of bytes read.
Previously, this wasn't an obvious issue because we always checked the
size before we read the attribute. It was still incorrect, but would
have required a race to trigger a bug.
Now, it's a more pressing issue because we try reading once with a
4KiB buffer before we check the size.
The fix is simple: make the target buffer 1 byte larger than it has to
be and make sure we always read less than the size of the buffer we
passed in.1 parent 99b48d8 commit df9ee49
2 files changed
+17
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
64 | 67 | | |
65 | | - | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
66 | 71 | | |
67 | 72 | | |
68 | 73 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
46 | 51 | | |
47 | 52 | | |
48 | 53 | | |
| |||
0 commit comments