Package: mtd-utils Version: 1:1.5.1-1.1rck1 Severity: normal Hello,
the kernel refuses to read more data from a MTD device than the device size. However, mtd_debug does not check the amount of data read as returned by read(2) and assumes the requested amount is always read when there is no error. Reading 8M data from a 4M flash chip results in 8M file containing the flash data at the start. Attaching patch to fix the issue. Thanks Michal -- System Information: Debian Release: 8.1 APT prefers stable APT policy: (900, 'stable'), (510, 'unstable'), (505, 'experimental'), (500, 'oldstable') Architecture: armhf (armv7l) Foreign Architectures: i386 Kernel: Linux 4.2.0-rc3-00168-gf94f5ae (SMP w/2 CPU cores; PREEMPT) Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Init: sysvinit (via /sbin/init) Versions of packages mtd-utils depends on: ii libc6 2.19-18 ii liblzo2-2 2.08-1.2 ii libuuid1 2.25.2-6 ii zlib1g 1:1.2.8.dfsg-2+b1 mtd-utils recommends no packages. mtd-utils suggests no packages. -- no debconf information
Index: mtd-utils-1.5.1/mtd_debug.c =================================================================== --- mtd-utils-1.5.1.orig/mtd_debug.c 2015-07-27 15:31:52.143449285 +0200 +++ mtd-utils-1.5.1/mtd_debug.c 2015-07-27 15:32:12.153449294 +0200 @@ -141,7 +141,10 @@ perror("read()"); goto err2; } - err = write(outfd, buf, size); + if (err < size) { + fprintf(stderr, "%s: short read, requested %#x, read %#x\n", __func__, size, err); + } + err = write(outfd, buf, err); if (err < 0) { fprintf(stderr, "%s: write, size %#x, n %#x\n", __func__, size, n); perror("write()");