make sure we null terminate the string we return in _readlink()
authorroot <root@rcn1.VSOFS1.COM>
Fri, 6 Mar 2009 03:19:21 +0000 (14:19 +1100)
committerroot <root@rcn1.VSOFS1.COM>
Fri, 6 Mar 2009 03:19:21 +0000 (14:19 +1100)
migrate/remote-cache.c

index e0decaaa77728a87f90188a479be10cb4245f177..59a0a24591e2d42f217399491ff8ef20a47c26e2 100644 (file)
@@ -978,13 +978,16 @@ static int remote_cache_readlink(const char *path, char *buf, size_t len)
        ssize_t lsize;
        int ret = 0;
 
-       DEBUG(DEBUG_DEBUG, (__location__ " READLINK %s\n", path));
+       DEBUG(DEBUG_DEBUG, (__location__ " READLINK %s len:%d\n", path, (int)len));
        old_path   = talloc_asprintf(mem_ctx, "%s/%s", remote, path);
        lsize = readlink(old_path, buf, len);
        if (lsize == -1) {
                ret = -errno;
                goto finished;
        }
+       if (lsize < len) {
+               buf[lsize] = 0;
+       }
 
 finished:
        talloc_free(mem_ctx);