diff options
author | jeff <jeff@FreeBSD.org> | 2013-08-09 03:24:48 +0000 |
---|---|---|
committer | jeff <jeff@FreeBSD.org> | 2013-08-09 03:24:48 +0000 |
commit | 31941e8d5db2bff6bbac59234d62b0a62f698f69 (patch) | |
tree | 1abc8c388c86ef0859c1c5df828574363486d523 /sys/ofed/include | |
parent | fd428c40becfb29227d4db32094c1c1c4f1bbf27 (diff) | |
download | FreeBSD-src-31941e8d5db2bff6bbac59234d62b0a62f698f69.zip FreeBSD-src-31941e8d5db2bff6bbac59234d62b0a62f698f69.tar.gz |
- Correctly handle various edge cases in sysfs emulation.
Sponsored by: EMC / Isilon Storage Division
Diffstat (limited to 'sys/ofed/include')
-rw-r--r-- | sys/ofed/include/linux/sysfs.h | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/sys/ofed/include/linux/sysfs.h b/sys/ofed/include/linux/sysfs.h index 4a763c8..c60a2b9 100644 --- a/sys/ofed/include/linux/sysfs.h +++ b/sys/ofed/include/linux/sysfs.h @@ -97,11 +97,14 @@ sysctl_handle_attr(SYSCTL_HANDLER_ARGS) error = -len; if (error != EIO) goto out; + buf[0] = '\0'; + } else if (len) { + len--; + if (len >= PAGE_SIZE) + len = PAGE_SIZE - 1; + /* Trim trailing newline. */ + buf[len] = '\0'; } - - /* Trim trailing newline. */ - len--; - buf[len] = '\0'; } /* Leave one trailing byte to append a newline. */ |