lkml.org 
[lkml]   [2007]   [Nov]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH] Smackv10: Smack rules grammar + their stateful parser
Date
On Nov 03, 2007, at 12:43:06, Ahmed S. Darwish wrote:
> Bashv3 builtin "echo" behaves very strangely to -EINVAL. It sends
> all the buffers that causes -EINVAL again in subsequent echo
> invocations.
>
> i.e.
> echo "Invalid Rule" > /smack/load # -EINVAL returned
> echo "Valid Rule" > /smack/load
>
> In seconod iteration, echo sends the first invalid buffer again
> then sends the new one. This causes a "Invalid Rule\nValid Rule"
> buffer sent to write().
>
> IMHO, this is a bug in builtin echo. The external /bin/echo doesn't
> cause such strange behaviour.

Actually, what causes problems here is something between a bug and a
feature in libc's buffering. Basically the -EINVAL error causes libc
to leave its data in the file-output buffer despite the file being
closed and reopened. Since a standalone echo just exits that buffer
is discarded, but for the bash builtin it hangs around in the buffer
for a while and ends up getting prepended to the following echo
statement. There's actually multiple ways to make this fail; this is
just the simplest.

Cheers,
Kyle Moffett

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2007-11-03 19:33    [W:0.114 / U:0.436 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site