Debian Bug report logs - #547902
dash: 'read' builtin reads only the first character from pipes or /proc files

version graph

Package: dash; Maintainer for dash is Andrej Shadura <[email protected]>; Source for dash is src:dash (PTS, buildd, popcon).

Reported by: Corin <[email protected]>

Date: Tue, 22 Sep 2009 13:54:09 UTC

Severity: important

Tags: patch, upstream

Merged with 547906, 595063

Found in versions dash/0.5.4-12, dash/0.5.12-2, dash/0.5.7-4, dash/0.5.6.1-1~exp2

Forwarded to https://www.spinics.net/lists/dash/msg00346.html

Reply or subscribe to this bug.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to [email protected], Gerrit Pape <[email protected]>:
Bug#547902; Package dash. (Tue, 22 Sep 2009 13:54:12 GMT) (full text, mbox, link).


Acknowledgement sent to Corin <[email protected]>:
New Bug report received and forwarded. Copy sent to Gerrit Pape <[email protected]>. (Tue, 22 Sep 2009 13:54:12 GMT) (full text, mbox, link).


Message #5 received at [email protected] (full text, mbox, reply):

From: Corin <[email protected]>
To: Debian Bug Tracking System <[email protected]>
Subject: dash only reads the first character from pipe (bash reads whole line)
Date: Tue, 22 Sep 2009 15:49:40 +0200
Package: dash
Version: 0.5.5.1-2.3
Severity: important


The 'read' command seems to only read the first character and not the whole line.

Example / comparison with bash:

# /bin/dash
# read MAX </proc/sys/net/netfilter/nf_conntrack_max
# echo $MAX
2

# /bin/bash
# read MAX </proc/sys/net/netfilter/nf_conntrack_max
# echo $MAX
262144


-- System Information:
Debian Release: squeeze/sid
  APT prefers testing
  APT policy: (990, 'testing'), (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.26-2-vserver-amd64 (SMP w/4 CPU cores)
Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages dash depends on:
ii  debianutils                  3.2.1       Miscellaneous utilities specific t
ii  dpkg                         1.15.3.1+b1 Debian package management system
ii  libc6                        2.9-25      GNU C Library: Shared libraries

dash recommends no packages.

dash suggests no packages.

-- debconf information:
* dash/sh: true




Merged 547902 547906. Request was from Raphael Geissert <[email protected]> to [email protected]. (Fri, 25 Sep 2009 05:06:03 GMT) (full text, mbox, link).


Information forwarded to [email protected], Gerrit Pape <[email protected]>:
Bug#547902; Package dash. (Tue, 29 Sep 2009 12:09:09 GMT) (full text, mbox, link).


Acknowledgement sent to [email protected]:
Extra info received and forwarded to list. Copy sent to Gerrit Pape <[email protected]>. (Tue, 29 Sep 2009 12:09:10 GMT) (full text, mbox, link).


Message #12 received at [email protected] (full text, mbox, reply):

From: Gerrit Pape <[email protected]>
To: Corin <[email protected]>, [email protected]
Subject: Re: Bug#547902: dash only reads the first character from pipe (bash reads whole line)
Date: Tue, 29 Sep 2009 11:59:55 +0000
On Tue, Sep 22, 2009 at 03:49:40PM +0200, Corin wrote:
> The 'read' command seems to only read the first character and not the whole line.
> 
> Example / comparison with bash:
> 
> # /bin/dash
> # read MAX </proc/sys/net/netfilter/nf_conntrack_max
> # echo $MAX
> 2
> 
> # /bin/bash
> # read MAX </proc/sys/net/netfilter/nf_conntrack_max
> # echo $MAX
> 262144

Hi, this doesn't look like a bug in dash, but in the kernel's
implementation of the /proc/sys/net/ hierarchy.  If you copy the file to
/tmp/, it works just fine.

cat <<EOT >t.c
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

int main(int argc, char **argv) {
	char c;
	int fd = open(argv[1], O_RDONLY);
	if (fd == -1) return 1;
	for (;;) {
		int i = read(fd, &c, 1);
		if (i == 0) break;
		if (i == -1) return 2;
		if (write(1, &c, 1) == -1) return 3;
	}
	write(1, "\n", 1);
	return 0;
}
EOT
gcc t.c
./a.out /proc/sys/net/unix/max_dgram_qlen
cat /proc/sys/net/unix/max_dgram_qlen
cp /proc/sys/net/unix/max_dgram_qlen /tmp/
./a.out /tmp/max_dgram_qlen

Regards, Gerrit.




Information forwarded to [email protected], Gerrit Pape <[email protected]>:
Bug#547902; Package dash. (Thu, 08 Oct 2009 11:57:11 GMT) (full text, mbox, link).


Acknowledgement sent to Netskin | Corin Langosch <[email protected]>:
Extra info received and forwarded to list. Copy sent to Gerrit Pape <[email protected]>. (Thu, 08 Oct 2009 11:57:11 GMT) (full text, mbox, link).


Message #17 received at [email protected] (full text, mbox, reply):

From: Netskin | Corin Langosch <[email protected]>
To: [email protected]
Subject: Re: Bug#547902: dash only reads the first character from pipe (bash reads whole line)
Date: Thu, 08 Oct 2009 13:34:40 +0200
Hi,

I'm still not sure if it's a kernel bug/misbehavior, as bash works fine 
on the same system. And even if it's a kernel bug, shouldn't dash 
contain the same work-around as bash seems to have?

Fact is, when upgrading debian (and so dash becomes the default shell) 
some applications break because of this. One example are munin plugins, 
which is where I discovered the bug/ regression. Changing the shebang 
line in the munin plugins from /bin/sh (symlink to /bin/dash) to 
/bin/bash solves the problems.

Corin






Bug reassigned from package 'dash' to 'linux-2.6'. Request was from Gerrit Pape <[email protected]> to [email protected]. (Tue, 13 Oct 2009 11:09:18 GMT) (full text, mbox, link).


Bug No longer marked as found in versions dash/0.5.5.1-2.3. Request was from Gerrit Pape <[email protected]> to [email protected]. (Tue, 13 Oct 2009 11:09:22 GMT) (full text, mbox, link).


Information forwarded to [email protected], Debian Kernel Team <[email protected]>:
Bug#547902; Package linux-2.6. (Tue, 13 Oct 2009 11:39:04 GMT) (full text, mbox, link).


Acknowledgement sent to Gerrit Pape <[email protected]>:
Extra info received and forwarded to list. Copy sent to Debian Kernel Team <[email protected]>. (Tue, 13 Oct 2009 11:39:05 GMT) (full text, mbox, link).


Message #26 received at [email protected] (full text, mbox, reply):

From: Gerrit Pape <[email protected]>
To: [email protected]
Cc: [email protected]
Subject: Re: Bug#547902: dash only reads the first character from pipe (bash reads whole line)
Date: Tue, 13 Oct 2009 11:13:01 +0000
tags 547902 + patch
quit

Hi, please see http://bugs.debian.org/547902

Here's a patch from Christian Hohnstaedt <[email protected]>

Thanks, Gerrit.

---
Testparameter:
for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19; do dd if=/proc/sys/net/ipv4/tcp_wmem bs=$i 2>/dev/null; done

for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19; do dd if=/proc/sys/net/ipv4/tcp_wmem skip=$i bs=1 2>/dev/null |wc -c ; done

diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 9270125..038df14 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -2117,17 +2117,16 @@ static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
 #define TMPBUFLEN 21
 	int *i, vleft, first=1, neg, val;
 	unsigned long lval;
-	size_t left, len;
+	size_t left, len, off;
 	
 	char buf[TMPBUFLEN], *p;
 	char __user *s = buffer;
 	
-	if (!tbl_data || !table->maxlen || !*lenp ||
-	    (*ppos && !write)) {
+	if (!tbl_data || !table->maxlen || !*lenp) {
 		*lenp = 0;
 		return 0;
 	}
-	
+	off = 0;
 	i = (int *) tbl_data;
 	vleft = table->maxlen / sizeof(*i);
 	left = *lenp;
@@ -2176,25 +2175,31 @@ static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
 			if (conv(&neg, &lval, i, 1, data))
 				break;
 		} else {
+			loff_t diff;
 			p = buf;
-			if (!first)
-				*p++ = '\t';
-	
 			if (conv(&neg, &lval, i, 0, data))
 				break;
 
-			sprintf(p, "%s%lu", neg ? "-" : "", lval);
-			len = strlen(buf);
-			if (len > left)
-				len = left;
-			if(copy_to_user(s, buf, len))
-				return -EFAULT;
-			left -= len;
-			s += len;
+			len = sprintf(p, "%s%s%lu", first ? "" : "\t",
+						neg ? "-" : "", lval);
+			diff = *ppos - off;
+			off += len;
+			if (diff > 0 && diff < len) {
+				p += diff;
+				len -= diff;
+			}
+			if (off > *ppos) {
+				if (len > left)
+					len = left;
+				if(copy_to_user(s, p, len))
+					return -EFAULT;
+				left -= len;
+				s += len;
+			}
 		}
 	}
 
-	if (!write && !first && left) {
+	if (!write && !first && left && off >= *ppos) {
 		if(put_user('\n', s))
 			return -EFAULT;
 		left--, s++;




Added tag(s) patch. Request was from Gerrit Pape <[email protected]> to [email protected]. (Tue, 13 Oct 2009 11:39:07 GMT) (full text, mbox, link).


Message sent on to Corin <[email protected]>:
Bug#547902. (Tue, 13 Oct 2009 11:39:12 GMT) (full text, mbox, link).


Information forwarded to [email protected], Debian Kernel Team <[email protected]>:
Bug#547902; Package linux-2.6. (Sat, 17 Oct 2009 00:45:03 GMT) (full text, mbox, link).


Acknowledgement sent to Ben Hutchings <[email protected]>:
Extra info received and forwarded to list. Copy sent to Debian Kernel Team <[email protected]>. (Sat, 17 Oct 2009 00:45:03 GMT) (full text, mbox, link).


Message #36 received at [email protected] (full text, mbox, reply):

From: Ben Hutchings <[email protected]>
To: Gerrit Pape <[email protected]>, [email protected]
Subject: Re: Bug#547902: dash only reads the first character from pipe (bash reads whole line)
Date: Sat, 17 Oct 2009 01:36:03 +0100
[Message part 1 (text/plain, inline)]
On Tue, 2009-10-13 at 11:13 +0000, Gerrit Pape wrote:
> tags 547902 + patch
> quit
> 
> Hi, please see http://bugs.debian.org/547902
> 
> Here's a patch from Christian Hohnstaedt <[email protected]>
[...]

Let us know when this change is accepted upstream.

Ben.

-- 
Ben Hutchings
It is impossible to make anything foolproof because fools are so ingenious.
[signature.asc (application/pgp-signature, inline)]

Added tag(s) moreinfo. Request was from Ben Hutchings <[email protected]> to [email protected]. (Sun, 18 Oct 2009 21:42:10 GMT) (full text, mbox, link).


Information forwarded to [email protected], Debian Kernel Team <[email protected]>:
Bug#547902; Package linux-2.6. (Fri, 13 Nov 2009 11:09:06 GMT) (full text, mbox, link).


Acknowledgement sent to Gerrit Pape <[email protected]>:
Extra info received and forwarded to list. Copy sent to Debian Kernel Team <[email protected]>. (Fri, 13 Nov 2009 11:09:06 GMT) (full text, mbox, link).


Message #43 received at [email protected] (full text, mbox, reply):

From: Gerrit Pape <[email protected]>
To: [email protected]
Subject: Re: Bug#547902: dash only reads the first character from pipe (bash reads whole line)
Date: Fri, 13 Nov 2009 11:00:26 +0000
On Sat, Oct 17, 2009 at 01:36:03AM +0100, Ben Hutchings wrote:
> On Tue, 2009-10-13 at 11:13 +0000, Gerrit Pape wrote:
> > tags 547902 + patch
> > quit
> > 
> > Hi, please see http://bugs.debian.org/547902
> > 
> > Here's a patch from Christian Hohnstaedt <[email protected]>
> [...]
> 
> Let us know when this change is accepted upstream.

Sorry, I neither forwarded it upstream, nor follow upstream development.

Regards, Gerrit.




Information forwarded to [email protected], Debian Kernel Team <[email protected]>:
Bug#547902; Package linux-2.6. (Fri, 13 Nov 2009 12:36:07 GMT) (full text, mbox, link).


Acknowledgement sent to Ben Hutchings <[email protected]>:
Extra info received and forwarded to list. Copy sent to Debian Kernel Team <[email protected]>. (Fri, 13 Nov 2009 12:36:07 GMT) (full text, mbox, link).


Message #48 received at [email protected] (full text, mbox, reply):

From: Ben Hutchings <[email protected]>
To: Gerrit Pape <[email protected]>, [email protected]
Subject: Re: Bug#547902: dash only reads the first character from pipe (bash reads whole line)
Date: Fri, 13 Nov 2009 12:34:10 +0000
[Message part 1 (text/plain, inline)]
On Fri, 2009-11-13 at 11:00 +0000, Gerrit Pape wrote:
> On Sat, Oct 17, 2009 at 01:36:03AM +0100, Ben Hutchings wrote:
> > On Tue, 2009-10-13 at 11:13 +0000, Gerrit Pape wrote:
> > > tags 547902 + patch
> > > quit
> > > 
> > > Hi, please see http://bugs.debian.org/547902
> > > 
> > > Here's a patch from Christian Hohnstaedt <[email protected]>
> > [...]
> > 
> > Let us know when this change is accepted upstream.
> 
> Sorry, I neither forwarded it upstream, nor follow upstream development.

Then we will not apply your patch.

Ben.

-- 
Ben Hutchings
The two most common things in the universe are hydrogen and stupidity.
[signature.asc (application/pgp-signature, inline)]

Added tag(s) wontfix. Request was from Ben Hutchings <[email protected]> to [email protected]. (Fri, 13 Nov 2009 12:36:08 GMT) (full text, mbox, link).


Message sent on to Corin <[email protected]>:
Bug#547902. (Fri, 13 Nov 2009 14:42:18 GMT) (full text, mbox, link).


Message #53 received at [email protected] (full text, mbox, reply):

From: Gerrit Pape <[email protected]>
To: [email protected]
Subject: [[email protected]: Re: Bug#547902: dash only reads the first character from pipe (bash reads whole line)]
Date: Fri, 13 Nov 2009 14:29:20 +0000
FYI.  Sorry, I can't help further.

Regards, Gerrit.


----- Forwarded message from Ben Hutchings <[email protected]> -----

From: Ben Hutchings <[email protected]>
To: Gerrit Pape <[email protected]>, [email protected]
Date: Fri, 13 Nov 2009 12:34:10 +0000
Subject: Re: Bug#547902: dash only reads the first character from pipe
 (bash reads whole line)

On Fri, 2009-11-13 at 11:00 +0000, Gerrit Pape wrote:
> On Sat, Oct 17, 2009 at 01:36:03AM +0100, Ben Hutchings wrote:
> > On Tue, 2009-10-13 at 11:13 +0000, Gerrit Pape wrote:
> > > tags 547902 + patch
> > > quit
> > > 
> > > Hi, please see http://bugs.debian.org/547902
> > > 
> > > Here's a patch from Christian Hohnstaedt <[email protected]>
> > [...]
> > 
> > Let us know when this change is accepted upstream.
> 
> Sorry, I neither forwarded it upstream, nor follow upstream development.

Then we will not apply your patch.

Ben.

-- 
Ben Hutchings
The two most common things in the universe are hydrogen and stupidity.



----- End forwarded message -----




Information forwarded to [email protected], Debian Kernel Team <[email protected]>:
Bug#547902; Package linux-2.6. (Wed, 18 Nov 2009 21:39:03 GMT) (full text, mbox, link).


Acknowledgement sent to Moritz Muehlenhoff <[email protected]>:
Extra info received and forwarded to list. Copy sent to Debian Kernel Team <[email protected]>. (Wed, 18 Nov 2009 21:39:03 GMT) (full text, mbox, link).


Message #58 received at [email protected] (full text, mbox, reply):

From: Moritz Muehlenhoff <[email protected]>
To: Gerrit Pape <[email protected]>
Cc: [email protected], [email protected], [email protected]
Subject: Re: Bug#547902: dash only reads the first character from pipe (bash reads whole line)
Date: Wed, 18 Nov 2009 22:13:48 +0100
On Tue, Oct 13, 2009 at 11:13:01AM +0000, Gerrit Pape wrote:
> tags 547902 + patch
> quit

[ Adding Christian to CC: ]

Christian, did you submit your patch upstream?

Cheers,
        Moritz

> Hi, please see http://bugs.debian.org/547902
> 
> Here's a patch from Christian Hohnstaedt <[email protected]>
> 
> Thanks, Gerrit.
>
> 
> ---
> Testparameter:
> for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19; do dd if=/proc/sys/net/ipv4/tcp_wmem bs=$i 2>/dev/null; done
> 
> for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19; do dd if=/proc/sys/net/ipv4/tcp_wmem skip=$i bs=1 2>/dev/null |wc -c ; done
> 
> diff --git a/kernel/sysctl.c b/kernel/sysctl.c
> index 9270125..038df14 100644
> --- a/kernel/sysctl.c
> +++ b/kernel/sysctl.c
> @@ -2117,17 +2117,16 @@ static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
>  #define TMPBUFLEN 21
>  	int *i, vleft, first=1, neg, val;
>  	unsigned long lval;
> -	size_t left, len;
> +	size_t left, len, off;
>  	
>  	char buf[TMPBUFLEN], *p;
>  	char __user *s = buffer;
>  	
> -	if (!tbl_data || !table->maxlen || !*lenp ||
> -	    (*ppos && !write)) {
> +	if (!tbl_data || !table->maxlen || !*lenp) {
>  		*lenp = 0;
>  		return 0;
>  	}
> -	
> +	off = 0;
>  	i = (int *) tbl_data;
>  	vleft = table->maxlen / sizeof(*i);
>  	left = *lenp;
> @@ -2176,25 +2175,31 @@ static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
>  			if (conv(&neg, &lval, i, 1, data))
>  				break;
>  		} else {
> +			loff_t diff;
>  			p = buf;
> -			if (!first)
> -				*p++ = '\t';
> -	
>  			if (conv(&neg, &lval, i, 0, data))
>  				break;
>  
> -			sprintf(p, "%s%lu", neg ? "-" : "", lval);
> -			len = strlen(buf);
> -			if (len > left)
> -				len = left;
> -			if(copy_to_user(s, buf, len))
> -				return -EFAULT;
> -			left -= len;
> -			s += len;
> +			len = sprintf(p, "%s%s%lu", first ? "" : "\t",
> +						neg ? "-" : "", lval);
> +			diff = *ppos - off;
> +			off += len;
> +			if (diff > 0 && diff < len) {
> +				p += diff;
> +				len -= diff;
> +			}
> +			if (off > *ppos) {
> +				if (len > left)
> +					len = left;
> +				if(copy_to_user(s, p, len))
> +					return -EFAULT;
> +				left -= len;
> +				s += len;
> +			}
>  		}
>  	}
>  
> -	if (!write && !first && left) {
> +	if (!write && !first && left && off >= *ppos) {
>  		if(put_user('\n', s))
>  			return -EFAULT;
>  		left--, s++;
> 
> 
> 




Message sent on to Corin <[email protected]>:
Bug#547902. (Wed, 18 Nov 2009 21:39:24 GMT) (full text, mbox, link).


Information forwarded to [email protected], Debian Kernel Team <[email protected]>:
Bug#547902; Package linux-2.6. (Thu, 19 Nov 2009 08:39:03 GMT) (full text, mbox, link).


Acknowledgement sent to Christian Hohnstaedt <[email protected]>:
Extra info received and forwarded to list. Copy sent to Debian Kernel Team <[email protected]>. (Thu, 19 Nov 2009 08:39:03 GMT) (full text, mbox, link).


Message #66 received at [email protected] (full text, mbox, reply):

From: Christian Hohnstaedt <[email protected]>
To: Moritz Muehlenhoff <[email protected]>
Cc: Gerrit Pape <[email protected]>, [email protected], [email protected], [email protected]
Subject: Re: Bug#547902: dash only reads the first character from pipe (bash reads whole line)
Date: Thu, 19 Nov 2009 09:27:47 +0100
On Wed, Nov 18, 2009 at 10:13:48PM +0100, Moritz Muehlenhoff wrote:
> On Tue, Oct 13, 2009 at 11:13:01AM +0000, Gerrit Pape wrote:
> > tags 547902 + patch
> > quit
> 
> [ Adding Christian to CC: ]
> 
> Christian, did you submit your patch upstream?

No, not yet.

It still has the problem that reading the value(s) bytewise returns garbage
if the value(s) change during reading.

But I can try to send it to lkml and see what they say.
Shall I point to this bug-report and may I add a "Tested-by" line ?

	Christian

> 
> Cheers,
>         Moritz
> 
> > Hi, please see http://bugs.debian.org/547902
> > 
> > Here's a patch from Christian Hohnstaedt <[email protected]>
> > 
> > Thanks, Gerrit.
> >
> > 
> > ---
> > Testparameter:
> > for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19; do dd if=/proc/sys/net/ipv4/tcp_wmem bs=$i 2>/dev/null; done
> > 
> > for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19; do dd if=/proc/sys/net/ipv4/tcp_wmem skip=$i bs=1 2>/dev/null |wc -c ; done
> > 
> > diff --git a/kernel/sysctl.c b/kernel/sysctl.c
> > index 9270125..038df14 100644
> > --- a/kernel/sysctl.c
> > +++ b/kernel/sysctl.c
> > @@ -2117,17 +2117,16 @@ static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
> >  #define TMPBUFLEN 21
> >  	int *i, vleft, first=1, neg, val;
> >  	unsigned long lval;
> > -	size_t left, len;
> > +	size_t left, len, off;
> >  	
> >  	char buf[TMPBUFLEN], *p;
> >  	char __user *s = buffer;
> >  	
> > -	if (!tbl_data || !table->maxlen || !*lenp ||
> > -	    (*ppos && !write)) {
> > +	if (!tbl_data || !table->maxlen || !*lenp) {
> >  		*lenp = 0;
> >  		return 0;
> >  	}
> > -	
> > +	off = 0;
> >  	i = (int *) tbl_data;
> >  	vleft = table->maxlen / sizeof(*i);
> >  	left = *lenp;
> > @@ -2176,25 +2175,31 @@ static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
> >  			if (conv(&neg, &lval, i, 1, data))
> >  				break;
> >  		} else {
> > +			loff_t diff;
> >  			p = buf;
> > -			if (!first)
> > -				*p++ = '\t';
> > -	
> >  			if (conv(&neg, &lval, i, 0, data))
> >  				break;
> >  
> > -			sprintf(p, "%s%lu", neg ? "-" : "", lval);
> > -			len = strlen(buf);
> > -			if (len > left)
> > -				len = left;
> > -			if(copy_to_user(s, buf, len))
> > -				return -EFAULT;
> > -			left -= len;
> > -			s += len;
> > +			len = sprintf(p, "%s%s%lu", first ? "" : "\t",
> > +						neg ? "-" : "", lval);
> > +			diff = *ppos - off;
> > +			off += len;
> > +			if (diff > 0 && diff < len) {
> > +				p += diff;
> > +				len -= diff;
> > +			}
> > +			if (off > *ppos) {
> > +				if (len > left)
> > +					len = left;
> > +				if(copy_to_user(s, p, len))
> > +					return -EFAULT;
> > +				left -= len;
> > +				s += len;
> > +			}
> >  		}
> >  	}
> >  
> > -	if (!write && !first && left) {
> > +	if (!write && !first && left && off >= *ppos) {
> >  		if(put_user('\n', s))
> >  			return -EFAULT;
> >  		left--, s++;
> > 
> > 
> > 
Christian Hohnstaedt

-- 
Christian Hohnstaedt / Project Manager Hardware and Manufacturing

Innominate Security Technologies AG / protecting industrial networks
tel: +49.30.921028.208 / fax: +49.30.921028.020
Rudower Chaussee 13, D-12489 Berlin / http://www.innominate.com

Register Court: AG Charlottenburg, HR B 81603
Management Board: Dirk Seewald
Chairman of the Supervisory Board: Volker Bibelhausen




Message sent on to Corin <[email protected]>:
Bug#547902. (Thu, 19 Nov 2009 08:39:07 GMT) (full text, mbox, link).


Information forwarded to [email protected], Debian Kernel Team <[email protected]>:
Bug#547902; Package linux-2.6. (Tue, 24 Nov 2009 21:21:06 GMT) (full text, mbox, link).


Acknowledgement sent to Moritz Muehlenhoff <[email protected]>:
Extra info received and forwarded to list. Copy sent to Debian Kernel Team <[email protected]>. (Tue, 24 Nov 2009 21:21:06 GMT) (full text, mbox, link).


Message #74 received at [email protected] (full text, mbox, reply):

From: Moritz Muehlenhoff <[email protected]>
To: Christian Hohnstaedt <[email protected]>
Cc: Gerrit Pape <[email protected]>, [email protected], [email protected]
Subject: Re: Bug#547902: dash only reads the first character from pipe (bash reads whole line)
Date: Tue, 24 Nov 2009 22:16:06 +0100
On Thu, Nov 19, 2009 at 09:27:47AM +0100, Christian Hohnstaedt wrote:
> On Wed, Nov 18, 2009 at 10:13:48PM +0100, Moritz Muehlenhoff wrote:
> > On Tue, Oct 13, 2009 at 11:13:01AM +0000, Gerrit Pape wrote:
> > > tags 547902 + patch
> > > quit
> > 
> > [ Adding Christian to CC: ]
> > 
> > Christian, did you submit your patch upstream?
> 
> No, not yet.

Please keep this bug CCed if you submit it.
 
> It still has the problem that reading the value(s) bytewise returns garbage
> if the value(s) change during reading.
> 
> But I can try to send it to lkml and see what they say.
> Shall I point to this bug-report and may I add a "Tested-by" line ?

I didn't test it myself, but maybe Corin can give feedback on this.

Cheers,
        Moritz




Message sent on to Corin <[email protected]>:
Bug#547902. (Tue, 24 Nov 2009 21:21:11 GMT) (full text, mbox, link).


Reply sent to Moritz Muehlenhoff <[email protected]>:
You have taken responsibility. (Fri, 06 May 2011 19:18:09 GMT) (full text, mbox, link).


Notification sent to Corin <[email protected]>:
Bug acknowledged by developer. (Fri, 06 May 2011 19:18:09 GMT) (full text, mbox, link).


Message #82 received at [email protected] (full text, mbox, reply):

From: Moritz Muehlenhoff <[email protected]>
To: Christian Hohnstaedt <[email protected]>
Cc: [email protected]
Subject: Re: Bug#547902: dash only reads the first character from pipe (bash reads whole line)
Date: Fri, 6 May 2011 21:15:45 +0200
On Tue, Nov 24, 2009 at 10:16:06PM +0100, Moritz Muehlenhoff wrote:
> On Thu, Nov 19, 2009 at 09:27:47AM +0100, Christian Hohnstaedt wrote:
> > On Wed, Nov 18, 2009 at 10:13:48PM +0100, Moritz Muehlenhoff wrote:
> > > On Tue, Oct 13, 2009 at 11:13:01AM +0000, Gerrit Pape wrote:
> > > > tags 547902 + patch
> > > > quit
> > > 
> > > [ Adding Christian to CC: ]
> > > 
> > > Christian, did you submit your patch upstream?
> > 
> > No, not yet.
> 
> Please keep this bug CCed if you submit it.

Closing due to lack of activity.

Cheers,
        Moritz




Reply sent to Moritz Muehlenhoff <[email protected]>:
You have taken responsibility. (Fri, 06 May 2011 19:18:10 GMT) (full text, mbox, link).


Notification sent to Corin Langosch <[email protected]>:
Bug acknowledged by developer. (Fri, 06 May 2011 19:18:10 GMT) (full text, mbox, link).


Information forwarded to [email protected], Debian Kernel Team <[email protected]>:
Bug#547902; Package linux-2.6. (Fri, 06 May 2011 19:30:03 GMT) (full text, mbox, link).


Acknowledgement sent to Jonathan Nieder <[email protected]>:
Extra info received and forwarded to list. Copy sent to Debian Kernel Team <[email protected]>. (Fri, 06 May 2011 19:30:03 GMT) (full text, mbox, link).


Message #92 received at [email protected] (full text, mbox, reply):

From: Jonathan Nieder <[email protected]>
To: [email protected]
Cc: Moritz Muehlenhoff <[email protected]>
Subject: Re: dash only reads the first character from pipe (bash reads whole line)
Date: Fri, 6 May 2011 14:26:07 -0500
reassign 547906 dash 0.5.6.1-1~exp2
reopen 547906
tags 547906 = patch
quit

Moritz Muehlenhoff wrote:

> Closing due to lack of activity.

I'll take it.  Will reassign back to linux-2.6 if there is progress.




Bug reassigned from package 'linux-2.6' to 'dash'. Request was from Jonathan Nieder <[email protected]> to [email protected]. (Fri, 06 May 2011 19:30:11 GMT) (full text, mbox, link).


Bug Marked as found in versions dash/0.5.6.1-1~exp2. Request was from Jonathan Nieder <[email protected]> to [email protected]. (Fri, 06 May 2011 19:30:12 GMT) (full text, mbox, link).


Did not alter fixed versions and reopened. Request was from Debbugs Internal Request <[email protected]> to [email protected]. (Fri, 06 May 2011 19:30:13 GMT) (full text, mbox, link).


Removed tag(s) moreinfo and wontfix. Request was from Jonathan Nieder <[email protected]> to [email protected]. (Fri, 06 May 2011 19:30:14 GMT) (full text, mbox, link).


Marked as found in versions dash/0.5.7-4. Request was from Gioele Barabucci <[email protected]> to [email protected]. (Thu, 12 Nov 2015 18:21:16 GMT) (full text, mbox, link).


Information forwarded to [email protected], Gerrit Pape <[email protected]>:
Bug#547902; Package dash. (Sat, 14 Nov 2015 13:03:04 GMT) (full text, mbox, link).


Acknowledgement sent to Gioele Barabucci <[email protected]>:
Extra info received and forwarded to list. Copy sent to Gerrit Pape <[email protected]>. (Sat, 14 Nov 2015 13:03:04 GMT) (full text, mbox, link).


Message #107 received at [email protected] (full text, mbox, reply):

From: Gioele Barabucci <[email protected]>
To: [email protected]
Subject: Re: Bug #547902: dash only reads the first character from pipe (bash reads whole line)
Date: Sat, 14 Nov 2015 13:53:04 +0100
Control: tags -1 upstream

This problem is known upstream, see 
<http://thread.gmane.org/gmane.comp.shells.dash/1174>.

The suggested workaround is

    MAX=$(cat /proc/.../file)

Regards,

--
Gioele Barabucci <[email protected]>



Added tag(s) upstream. Request was from Gioele Barabucci <[email protected]> to [email protected]. (Sat, 14 Nov 2015 13:03:04 GMT) (full text, mbox, link).


Set Bug forwarded-to-address to 'http://thread.gmane.org/gmane.comp.shells.dash/1174'. Request was from Gioele Barabucci <[email protected]> to [email protected]. (Tue, 17 Nov 2015 19:09:04 GMT) (full text, mbox, link).


Marked as found in versions dash/0.5.4-12. Request was from Gioele Barabucci <[email protected]> to [email protected]. (Fri, 20 Nov 2015 00:45:06 GMT) (full text, mbox, link).


Merged 547902 547906 595063 Request was from Gioele Barabucci <[email protected]> to [email protected]. (Fri, 20 Nov 2015 00:45:09 GMT) (full text, mbox, link).


Changed Bug title to 'dash: 'read' builtin reads only the first character from pipes or /proc files' from 'dash only reads the first character from pipe (bash reads whole line)' Request was from Gioele Barabucci <[email protected]> to [email protected]. (Fri, 20 Nov 2015 00:45:11 GMT) (full text, mbox, link).


Changed Bug forwarded-to-address to 'https://www.spinics.net/lists/dash/msg00348.html' from 'http://thread.gmane.org/gmane.comp.shells.dash/1174'. Request was from Gioele Barabucci <[email protected]> to [email protected]. (Sat, 15 Jul 2023 07:54:02 GMT) (full text, mbox, link).


Marked as found in versions dash/0.5.12-2. Request was from Gioele Barabucci <[email protected]> to [email protected]. (Sat, 15 Jul 2023 07:54:07 GMT) (full text, mbox, link).


Changed Bug forwarded-to-address to 'https://www.spinics.net/lists/dash/msg00346.html' from 'https://www.spinics.net/lists/dash/msg00348.html'. Request was from Gioele Barabucci <[email protected]> to [email protected]. (Sat, 15 Jul 2023 07:57:06 GMT) (full text, mbox, link).


Information forwarded to [email protected], Andrej Shadura <[email protected]>:
Bug#547902; Package dash. (Sun, 19 May 2024 10:36:04 GMT) (full text, mbox, link).


Acknowledgement sent to Herbert Xu <[email protected]>:
Extra info received and forwarded to list. Copy sent to Andrej Shadura <[email protected]>. (Sun, 19 May 2024 10:36:04 GMT) (full text, mbox, link).


Message #128 received at [email protected] (full text, mbox, reply):

From: Herbert Xu <[email protected]>
To: [email protected]
Subject: Upstream fix coming soon
Date: Sun, 19 May 2024 18:08:47 +0800
This will be fixed upstream soon with

https://patchwork.kernel.org/project/dash/patch/fd52d05affd400c2c2f2ba238ff83555d11ca648.1716096097.git.herbert@gondor.apana.org.au/

Cheers,
-- 
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt



Send a report that this bug log contains spam.


Debian bug tracking system administrator <[email protected]>. Last modified: Tue May 13 12:23:15 2025; Machine Name: buxtehude

Debian Bug tracking system

Debbugs is free software and licensed under the terms of the GNU General Public License version 2. The current version can be obtained from https://bugs.debian.org/debbugs-source/.

Copyright © 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson, 2005-2017 Don Armstrong, and many other contributors.