summaryrefslogtreecommitdiff
path: root/src/internal/slibtool_readlink_impl.h
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2020-02-01 01:26:09 +0000
committermidipix <writeonce@midipix.org>2020-02-01 01:26:09 +0000
commit0ee9587725ac84ec0ea0c65aea144d380e96fc1d (patch)
tree38403143f53604e32e774cbe0b3059202dcbdc85 /src/internal/slibtool_readlink_impl.h
parentdf790e957898e4b3d366580c3ed4c7cac03992d6 (diff)
downloadslibtool-0ee9587725ac84ec0ea0c65aea144d380e96fc1d.tar.bz2
slibtool-0ee9587725ac84ec0ea0c65aea144d380e96fc1d.tar.xz
internals: slbt_readlink(): set errno to ENOBUFS as needed.
Diffstat (limited to 'src/internal/slibtool_readlink_impl.h')
-rw-r--r--src/internal/slibtool_readlink_impl.h8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/internal/slibtool_readlink_impl.h b/src/internal/slibtool_readlink_impl.h
index c29b2d2..644a638 100644
--- a/src/internal/slibtool_readlink_impl.h
+++ b/src/internal/slibtool_readlink_impl.h
@@ -8,6 +8,7 @@
#define SLIBTOOL_READLINK_IMPL_H
#include <unistd.h>
+#include <errno.h>
static inline int slbt_readlink(
const char * restrict path,
@@ -16,11 +17,12 @@ static inline int slbt_readlink(
{
ssize_t ret;
- if ((ret = readlink(path,buf,bufsize)) <= 0)
+ if ((ret = readlink(path,buf,bufsize)) <= 0) {
return -1;
- else if (ret == bufsize)
+ } else if (ret == bufsize) {
+ errno = ENOBUFS;
return -1;
- else {
+ } else {
buf[ret] = 0;
return 0;
}