[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    possible bug in PtyProcess
From:       Andre Charbonneau <gexcfxyy () umail ! corel ! com>
Date:       2000-12-04 20:15:57
[Download RAW message or body]

Hi
I am currently having some problem with kdepasswd and while debugging it I 
think I found a bug in PtyProcess.  In process.cpp you will find the 
following code:

QCString PtyProcess::readLine(bool block)
{
    int pos;
    QCString ret;

    if (!m_Inbuf.isEmpty()) 
    {
        pos = m_Inbuf.find('\n');
        if (pos != -1) 
        {
            ret = m_Inbuf.left(pos);
            m_Inbuf = m_Inbuf.mid(pos+1);
            return ret;
        }
    }

...

The above peice of code causes the kdepasswd application to hang on my 
system.  The reason for this is that a line containing a '\n' but not 
ending with a '\n' is read by the "read()" system call.  The left part 
(before the '\n' is parsed, but because of the above code, the right part 
is not parsed since its not ending with a '\n'.  This will cause the 
kdepasswd app to hand since it will call the "read()" system call again 
while the passwd utility is waiting for user input.

To fix this problem, I suggest we do something like this:

QCString PtyProcess::readLine(bool block)
{
    int pos;
    QCString ret;

    if (!m_Inbuf.isEmpty()) 
    {
        pos = m_Inbuf.find('\n');
        if (pos != -1) 
        {
            ret = m_Inbuf.left(pos);
            m_Inbuf = m_Inbuf.mid(pos+1);
            return ret;
        }
        else  // This is the code that should fix the problem...
        {
                ret = m_Inbuf;
                m_Inbuf = "";
                return ret;
        }
    }

Did anyone had similar problems with PtyProcess before?
Does this make any sense at all?

Thanks,
-- 
Andre Charbonneau
GNU Linux Software developer  (Globalization)
Corel Corporation
-- 
The address in the headers is not the poster's real email address.  Do not send
private mail to the poster using your mailer's "reply" feature.  CC's of mail 
to mailing lists are OK.  Problem reports to "postmaster@umail.corel.com".  
The poster's email address is "andrec@corel.com".
 
>> Visit http://master.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic