aboutsummaryrefslogtreecommitdiff
path: root/example/hello.c
diff options
context:
space:
mode:
Diffstat (limited to 'example/hello.c')
-rw-r--r--example/hello.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/example/hello.c b/example/hello.c
index da2a9ee..040c835 100644
--- a/example/hello.c
+++ b/example/hello.c
@@ -60,10 +60,18 @@ static int hello_open(const char *path, int flags)
static int hello_read(const char *path, char *buf, size_t size, off_t offset)
{
+ size_t len;
if(strcmp(path, hello_path) != 0)
return -ENOENT;
- memcpy(buf, hello_str + offset, size);
+ len = strlen(hello_str);
+ if (offset < len) {
+ if (offset + size > len)
+ size = len - offset;
+ memcpy(buf, hello_str + offset, size);
+ } else
+ size = 0;
+
return size;
}