summaryrefslogtreecommitdiff
path: root/libdiskfs
diff options
context:
space:
mode:
authorJustus Winter <4winter@informatik.uni-hamburg.de>2014-03-20 13:34:02 +0100
committerJustus Winter <4winter@informatik.uni-hamburg.de>2014-03-25 08:52:23 +0100
commit52fdfc82a1ceef6251f816c64fc64fc78bd9b3e8 (patch)
treedcf3f736364da023c721576f7c9122117319feb5 /libdiskfs
parent2d9c5530456fce1b047fedf83ff48412509b7164 (diff)
libdiskfs: fix string termination
Found using the Clang Static Analyzer. * libdiskfs/fsys-getroot.c (diskfs_S_fsys_getroot): Fix string termination.
Diffstat (limited to 'libdiskfs')
-rw-r--r--libdiskfs/fsys-getroot.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/libdiskfs/fsys-getroot.c b/libdiskfs/fsys-getroot.c
index 52122146..10793c87 100644
--- a/libdiskfs/fsys-getroot.c
+++ b/libdiskfs/fsys-getroot.c
@@ -101,15 +101,17 @@ diskfs_S_fsys_getroot (struct diskfs_control *pt,
{
/* Handle symlink interpretation */
char pathbuf[diskfs_root_node->dn_stat.st_size + 1];
- size_t amt;
if (diskfs_read_symlink_hook)
err = (*diskfs_read_symlink_hook) (diskfs_root_node, pathbuf);
if (!diskfs_read_symlink_hook || err == EINVAL)
- err = diskfs_node_rdwr (diskfs_root_node, pathbuf, 0,
+ {
+ size_t amt = 0;
+ err = diskfs_node_rdwr (diskfs_root_node, pathbuf, 0,
diskfs_root_node->dn_stat.st_size, 0,
0, &amt);
- pathbuf[amt] = '\0';
+ pathbuf[amt] = '\0';
+ }
pthread_mutex_unlock (&diskfs_root_node->lock);
pthread_rwlock_unlock (&diskfs_fsys_lock);