This is the mail archive of the
ecos-discuss@sourceware.cygnus.com
mailing list for the eCos project.
Re: Error in io\serial\current\src\common\tty.c
- To: Alexander Hering <Hering at esk dot fhg dot de>
- Subject: Re: [ECOS] Error in io\serial\current\src\common\tty.c
- From: Gary Thomas <gthomas at redhat dot com>
- Date: Fri, 28 Jan 2000 08:31:13 -0700 (MST)
- Cc: eCos Discussion <ecos-discuss at sourceware dot cygnus dot com>
On 28-Jan-00 Alexander Hering wrote:
>
> This is a copy of the actual version in CVS:
>
> cyg_uint32 size, clen;
>
> if ((c == '\b') || (c == 0x7F)) {
> size -= 2; // erase one character + 'backspace' char
> ==> if (size < 0) {
> size = 0;
> } else if (priv->dev_info.tty_in_flags & CYG_TTY_IN_FLAGS_ECHO) {
> clen = 3;
> cyg_io_write(chan, "\b \b", &clen);
> }
>
> There is still the same problem. The variable size cannot be lower
> than zero, because it is an unsigned type.
>
Good catch. Use this patch to fix it.
Index: io/serial/current//src/common/tty.c
===================================================================
RCS file: /local/cvsfiles/ecc/ecc/io/serial/current/src/common/tty.c,v
retrieving revision 1.8
diff -u -5 -p -r1.8 tty.c
--- io/serial/current//src/common/tty.c 2000/01/28 03:54:54 1.8
+++ io/serial/current//src/common/tty.c 2000/01/28 15:29:15
@@ -191,11 +191,12 @@ static Cyg_ErrNo
tty_read(cyg_io_handle_t handle, void *_buf, cyg_uint32 *len)
{
cyg_devtab_entry_t *t = (cyg_devtab_entry_t *)handle;
struct tty_private_info *priv = (struct tty_private_info *)t->priv;
cyg_io_handle_t chan = (cyg_io_handle_t)priv->dev_handle;
- cyg_uint32 size, clen;
+ cyg_uint32 clen;
+ cyg_int32 size;
Cyg_ErrNo res;
cyg_uint8 c;
cyg_uint8 *buf = (cyg_uint8 *)_buf;
// assert(chan)
size = 0;
> Gary Thomas schrieb:
>>
>> A fix for this problem has already been installed.
>>
>> We suggest that you use CVS to keep track of the [very] latest
>> eCos sources. See our web page (http://sourceware.cygnus.com/ecos)
>> for the details.
>>
>> On 28-Jan-00 Alexander Hering wrote:
>> > Hello,
>> >
>> > we have found an error in the tty driver.
>> > When i press the backspace key, when no more characters are in the
>> > buffer, the last input is printed again.
>> >
>> > In function tty_read size is declared as unsigned int, and must not be
>> > tested against a value below zero.
>> >
>> > ====> cyg_uint32 size, clen;
>> >
>> > if ((c == '\b') || (c == 0x7F)) {
>> > size -= 2; // erase one character + 'backspace' char
>> > ====> if (size < 0) size = 0;
>> >
>> > Greetings
>> >
>> > Alex
>> >
>> > --
>> > Fraunhofer-Einrichtung
>> > Systeme der Kommunikationstechnik
>> >
>> > Alexander Hering Hansastraße 32
>> > Dipl.-Ing. D-80686 München
>> > Telefon: +49(0)89/547088-37
>> > E-Mail: Hering@esk.fhg.de Telefax: +49(0)89/547088-25
>
> --
> Fraunhofer-Einrichtung
> Systeme der Kommunikationstechnik
>
> Alexander Hering Hansastraße 32
> Dipl.-Ing. D-80686 München
> Telefon: +49(0)89/547088-37
> E-Mail: Hering@esk.fhg.de Telefax: +49(0)89/547088-25