mirror of https://github.com/kdave/btrfs-progs synced 2025-01-27 07:53:27 +00:00

btrfs-progs: restore: Fix input buffer handling

fgets consumes n-1 bytes from input buffer.

When a user types y\n, the newline is left in the buffer.  As a result,
the next fgets uses that \n as answer without waiting for the user to
type.

This patch also fix a bug that dereference the ret without checking if
it's NULL.

* Consumes the `\n` from stdin buffer
* Avoid NULL pointer dereference: treat EOF as default value

Pull-request: #182
Author: pjw91 <mail6543210@yahoo.com.tw>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
pjw91 2019-06-19 02:24:53 +08:00 committed by David Sterba
parent 5dfbc7c42a
commit 064341dca9