summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJose Antonio Ortega Ruiz <jao@gnu.org>2019-03-20 00:06:22 +0000
committerJose Antonio Ortega Ruiz <jao@gnu.org>2019-03-20 00:06:22 +0000
commitceec5c6d538a88867a92d826e33cddae6a80c545 (patch)
tree6c96d5e3098a822d7a42a81bb51520209887a629
parent5ccc36c2b6a3344bb1ef72307370bbfe300573d3 (diff)
downloadmdk-ceec5c6d538a88867a92d826e33cddae6a80c545.tar.gz
mdk-ceec5c6d538a88867a92d826e33cddae6a80c545.tar.bz2
Fix: correctly rewind tape
According to the specification, if M < 0, the tape is skipped backwards M blocks, or to the beginning of the tape, whichever comes first. In the implementation, we don't check to verify that we aren't seeking past the beginning of the file. This causes fseek(3) to fail, and it leaves us at the position we were at. Diagnosis and fix by Kevin Brunelle.
-rw-r--r--mixlib/xmix_device.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/mixlib/xmix_device.c b/mixlib/xmix_device.c
index 0c07549..8d4084c 100644
--- a/mixlib/xmix_device.c
+++ b/mixlib/xmix_device.c
@@ -155,7 +155,7 @@ ioc_ (mix_device_t *dev, mix_short_t arg)
if (dev->type >= mix_dev_TAPE_0 && dev->type <= mix_dev_TAPE_7)
{
- if (m == 0) rewind (file);
+ if (m == 0 || (ftell (file) + m <= 0 )) rewind (file);
else fseek (file, m, SEEK_CUR);
}
if (dev->type >= mix_dev_DISK_0 && dev->type <= mix_dev_DISK_7)