Added check to prevent token overflow, changed strncpy to memcpy for writing to src buffer