Re: [pgadmin-hackers] [PATCH] Fix crash when disabling auto commit

2015-06-14 Thread John Obaterspok
Hello Sanket,

Just enter "rollback" and exec

The
 while(wxIsalpha(query.GetChar(wordlen)))
  wordlen++;

As the 'k' in rollback is a char it also tries the next character (worklen
= 8) which causes out of bounds check.

-- john


2015-06-12 13:25 GMT+02:00 Sanket Mehta :

> Hi John,
>
> I have tried to reproduce the scenario but not able to reproduce the crash
> in my system.
> can you please provide your steps which causes crash on your machine?
>
> Regards,
> Sanket Mehta
> Sr Software engineer
> Enterprisedb
>
> On Fri, Jun 12, 2015 at 11:50 AM, Sanket Mehta <
> sanket.me...@enterprisedb.com> wrote:
>
>> Hi,
>>
>> I am looking into the same and few other issues in code and will send the
>> patch soon.
>>
>>
>> Regards,
>> Sanket Mehta
>> Sr Software engineer
>> Enterprisedb
>>
>> On Fri, Jun 12, 2015 at 1:49 AM, John Obaterspok <
>> john.obaters...@gmail.com> wrote:
>>
>>> Fix crash when string has only alphas (like 'rollback')
>>>
>>> diff --git a/pgadmin/frm/frmQuery.cpp b/pgadmin/frm/frmQuery.cpp
>>> index b5a2f56..110bbc7 100644
>>> --- a/pgadmin/frm/frmQuery.cpp
>>> +++ b/pgadmin/frm/frmQuery.cpp
>>> @@ -2522,7 +2522,7 @@ bool frmQuery::isBeginNotRequired(wxString query)
>>>   /*
>>>   * Check word length (since "beginx" is not "begin").
>>>   */
>>> - while(wxIsalpha(query.GetChar(wordlen)))
>>> + while(wordlen < query.Length() && wxIsalpha(query.GetChar(wordlen)))
>>>   wordlen++;
>>>
>>>   /*
>>>
>>
>>
>


Re: [pgadmin-hackers] [PATCH] Fix crash when disabling auto commit

2015-06-14 Thread Sanket Mehta
Hi John,

I have tried the same, I am not getting any out of the bounds error, it
simply comes out of the while loop.

Regards,
Sanket Mehta
Sr Software engineer
Enterprisedb

On Sun, Jun 14, 2015 at 2:00 PM, John Obaterspok 
wrote:

> Hello Sanket,
>
> Just enter "rollback" and exec
>
> The
>  while(wxIsalpha(query.GetChar(wordlen)))
>   wordlen++;
>
> As the 'k' in rollback is a char it also tries the next character (worklen
> = 8) which causes out of bounds check.
>
> -- john
>
>
> 2015-06-12 13:25 GMT+02:00 Sanket Mehta :
>
>> Hi John,
>>
>> I have tried to reproduce the scenario but not able to reproduce the
>> crash in my system.
>> can you please provide your steps which causes crash on your machine?
>>
>> Regards,
>> Sanket Mehta
>> Sr Software engineer
>> Enterprisedb
>>
>> On Fri, Jun 12, 2015 at 11:50 AM, Sanket Mehta <
>> sanket.me...@enterprisedb.com> wrote:
>>
>>> Hi,
>>>
>>> I am looking into the same and few other issues in code and will send
>>> the patch soon.
>>>
>>>
>>> Regards,
>>> Sanket Mehta
>>> Sr Software engineer
>>> Enterprisedb
>>>
>>> On Fri, Jun 12, 2015 at 1:49 AM, John Obaterspok <
>>> john.obaters...@gmail.com> wrote:
>>>
 Fix crash when string has only alphas (like 'rollback')

 diff --git a/pgadmin/frm/frmQuery.cpp b/pgadmin/frm/frmQuery.cpp
 index b5a2f56..110bbc7 100644
 --- a/pgadmin/frm/frmQuery.cpp
 +++ b/pgadmin/frm/frmQuery.cpp
 @@ -2522,7 +2522,7 @@ bool frmQuery::isBeginNotRequired(wxString query)
   /*
   * Check word length (since "beginx" is not "begin").
   */
 - while(wxIsalpha(query.GetChar(wordlen)))
 + while(wordlen < query.Length() && wxIsalpha(query.GetChar(wordlen)))
   wordlen++;

   /*

>>>
>>>
>>
>


Re: [pgadmin-hackers] SSH error messages not shown

2015-06-14 Thread Dave Page
Akshay, can you look into this please?

-- 
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK:http://www.enterprisedb.com
The Enterprise PostgreSQL Company

> On 13 Jun 2015, at 16:22, Jacek Wielemborek  wrote:
> 
> Hi,
> 
> When an libssh2 call fails, pgAdmin III just shows the error code and
> nothing else. Consider the following patch - this is what I created
> while wondering why my hostkeys don't work:
> 
> diff --git a/pgadmin/utils/sshTunnel.cpp b/pgadmin/utils/sshTunnel.cpp
> index fd80214..e15f764 100644
> --- a/pgadmin/utils/sshTunnel.cpp
> +++ b/pgadmin/utils/sshTunnel.cpp
> @@ -201,8 +201,13 @@ bool CSSHTunnelThread::Initialize()
> #endif
>if (rc)
>{
> -
> LogSSHTunnelErrors(wxString::Format(_("SSH error: Authentication by
> identity file failed with error code %d"), rc), GetId());
> +   char* errmsg;
> +   int errmsg_len;
> +   libssh2_session_last_error(m_session,
> &errmsg, &errmsg_len, 0);
> +   wxString errmsg_s(errmsg, wxConvLibc);
> +
> LogSSHTunnelErrors(wxString::Format(_("SSH error: Authentication by
> identity file failed with error code %d [%s]"), rc, errmsg_s.c_str()),
> GetId());
>Cleanup();
> +   free(errmsg);
>return false;
>}
>}
> 
> Perhaps we could use this kind of routines wherever rc is being checked?
> 
> Cheers,
> d33tah
> 


Re: [pgadmin-hackers] valgrind complains a lot when trying to establish an SSH tunnel while giving wrong key

2015-06-14 Thread Dave Page
Akshay, can you look into this please? Do we need to update the libssh code 
from upstream?

-- 
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK:http://www.enterprisedb.com
The Enterprise PostgreSQL Company

> On 13 Jun 2015, at 16:20, Jacek Wielemborek  wrote:
> 
> Hi,
> 
> Tested on Fedora 21 x86_64 with the latest locally built git version of
> pgadmin3. Feel free to ask any other questions.
> 
> Cheers,
> d33tah
> 


Re: [pgadmin-hackers] [PATCH] Fix crash when disabling auto commit

2015-06-14 Thread Ashesh Vashi
John,

As I understand correctly, 8th character will be '\0' (null character).
Hence - wxIsAlpha() will come out of the loop in general.

But - it is possible every platform has different behaviour for wxWidgets.
Can you please be specific about the operating system?

--
Thanks & Regards,

Ashesh Vashi
EnterpriseDB (Software Architect)

[Sent through mobile]
On Jun 14, 2015 2:41 PM, "Sanket Mehta" 
wrote:

> Hi John,
>
> I have tried the same, I am not getting any out of the bounds error, it
> simply comes out of the while loop.
>
> Regards,
> Sanket Mehta
> Sr Software engineer
> Enterprisedb
>
> On Sun, Jun 14, 2015 at 2:00 PM, John Obaterspok <
> john.obaters...@gmail.com> wrote:
>
>> Hello Sanket,
>>
>> Just enter "rollback" and exec
>>
>> The
>>  while(wxIsalpha(query.GetChar(wordlen)))
>>   wordlen++;
>>
>> As the 'k' in rollback is a char it also tries the next character
>> (worklen = 8) which causes out of bounds check.
>>
>> -- john
>>
>>
>> 2015-06-12 13:25 GMT+02:00 Sanket Mehta :
>>
>>> Hi John,
>>>
>>> I have tried to reproduce the scenario but not able to reproduce the
>>> crash in my system.
>>> can you please provide your steps which causes crash on your machine?
>>>
>>> Regards,
>>> Sanket Mehta
>>> Sr Software engineer
>>> Enterprisedb
>>>
>>> On Fri, Jun 12, 2015 at 11:50 AM, Sanket Mehta <
>>> sanket.me...@enterprisedb.com> wrote:
>>>
 Hi,

 I am looking into the same and few other issues in code and will send
 the patch soon.


 Regards,
 Sanket Mehta
 Sr Software engineer
 Enterprisedb

 On Fri, Jun 12, 2015 at 1:49 AM, John Obaterspok <
 john.obaters...@gmail.com> wrote:

> Fix crash when string has only alphas (like 'rollback')
>
> diff --git a/pgadmin/frm/frmQuery.cpp b/pgadmin/frm/frmQuery.cpp
> index b5a2f56..110bbc7 100644
> --- a/pgadmin/frm/frmQuery.cpp
> +++ b/pgadmin/frm/frmQuery.cpp
> @@ -2522,7 +2522,7 @@ bool frmQuery::isBeginNotRequired(wxString query)
>   /*
>   * Check word length (since "beginx" is not "begin").
>   */
> - while(wxIsalpha(query.GetChar(wordlen)))
> + while(wordlen < query.Length() && wxIsalpha(query.GetChar(wordlen)))
>   wordlen++;
>
>   /*
>


>>>
>>
>


Re: [pgadmin-hackers] SSH error messages not shown

2015-06-14 Thread Akshay Joshi
Sure.

On Sun, Jun 14, 2015 at 3:13 PM, Dave Page  wrote:

> Akshay, can you look into this please?
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK:http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
> On 13 Jun 2015, at 16:22, Jacek Wielemborek  wrote:
>
> Hi,
>
> When an libssh2 call fails, pgAdmin III just shows the error code and
> nothing else. Consider the following patch - this is what I created
> while wondering why my hostkeys don't work:
>
> diff --git a/pgadmin/utils/sshTunnel.cpp b/pgadmin/utils/sshTunnel.cpp
> index fd80214..e15f764 100644
> --- a/pgadmin/utils/sshTunnel.cpp
> +++ b/pgadmin/utils/sshTunnel.cpp
> @@ -201,8 +201,13 @@ bool CSSHTunnelThread::Initialize()
> #endif
>if (rc)
>{
> -
> LogSSHTunnelErrors(wxString::Format(_("SSH error: Authentication by
> identity file failed with error code %d"), rc), GetId());
> +   char* errmsg;
> +   int errmsg_len;
> +   libssh2_session_last_error(m_session,
> &errmsg, &errmsg_len, 0);
> +   wxString errmsg_s(errmsg, wxConvLibc);
> +
> LogSSHTunnelErrors(wxString::Format(_("SSH error: Authentication by
> identity file failed with error code %d [%s]"), rc, errmsg_s.c_str()),
> GetId());
>Cleanup();
> +   free(errmsg);
>return false;
>}
>}
>
> Perhaps we could use this kind of routines wherever rc is being checked?
>
> Cheers,
> d33tah
>
>


-- 
*Akshay Joshi*
*Principal Software Engineer *



*Phone: +91 20-3058-9517Mobile: +91 976-788-8246*


Re: [pgadmin-hackers] valgrind complains a lot when trying to establish an SSH tunnel while giving wrong key

2015-06-14 Thread Akshay Joshi
Sure.

On Sun, Jun 14, 2015 at 3:13 PM, Dave Page  wrote:

> Akshay, can you look into this please? Do we need to update the libssh
> code from upstream?
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK:http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
> On 13 Jun 2015, at 16:20, Jacek Wielemborek  wrote:
>
> Hi,
>
> Tested on Fedora 21 x86_64 with the latest locally built git version of
> pgadmin3. Feel free to ask any other questions.
>
> Cheers,
> d33tah
>
> 
>
>


-- 
*Akshay Joshi*
*Principal Software Engineer *



*Phone: +91 20-3058-9517Mobile: +91 976-788-8246*


Re: [pgadmin-hackers] SSH error messages not shown

2015-06-14 Thread Akshay Joshi
Hi Jacek

On Mon, Jun 15, 2015 at 10:40 AM, Akshay Joshi  wrote:

> Sure.
>
> On Sun, Jun 14, 2015 at 3:13 PM, Dave Page  wrote:
>
>> Akshay, can you look into this please?
>>
>> --
>> Dave Page
>> Blog: http://pgsnake.blogspot.com
>> Twitter: @pgsnake
>>
>> EnterpriseDB UK:http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>> On 13 Jun 2015, at 16:22, Jacek Wielemborek  wrote:
>>
>> Hi,
>>
>> When an libssh2 call fails, pgAdmin III just shows the error code and
>> nothing else. Consider the following patch - this is what I created
>> while wondering why my hostkeys don't work:
>>
>> diff --git a/pgadmin/utils/sshTunnel.cpp b/pgadmin/utils/sshTunnel.cpp
>> index fd80214..e15f764 100644
>> --- a/pgadmin/utils/sshTunnel.cpp
>> +++ b/pgadmin/utils/sshTunnel.cpp
>> @@ -201,8 +201,13 @@ bool CSSHTunnelThread::Initialize()
>> #endif
>>if (rc)
>>{
>> -
>> LogSSHTunnelErrors(wxString::Format(_("SSH error: Authentication by
>> identity file failed with error code %d"), rc), GetId());
>> +   char* errmsg;
>> +   int errmsg_len;
>> +   libssh2_session_last_error(m_session,
>> &errmsg, &errmsg_len, 0);
>> +   wxString errmsg_s(errmsg, wxConvLibc);
>> +
>> LogSSHTunnelErrors(wxString::Format(_("SSH error: Authentication by
>> identity file failed with error code %d [%s]"), rc, errmsg_s.c_str()),
>> GetId());
>>Cleanup();
>> +   free(errmsg);
>>return false;
>>}
>>}
>>
>> Perhaps we could use this kind of routines wherever rc is being checked?
>>
>>I have reviewed your patch and it looks good to have error message
with error number. I have made some changes in the "LogSSHTunnelErrors"
function to avoid duplicate logic for each error message. I have added one
default parameter of the session object in the "LogSSHTunnelErrors"
function. If we would like to log error message with error number, will
have to pass session object. Attached is the modified patch, can you please
check it is working or not for your test case.

>
>>
>> Cheers,
>> d33tah
>>
>>
>
>
> --
> *Akshay Joshi*
> *Principal Software Engineer *
>
>
>
> *Phone: +91 20-3058-9517Mobile: +91 976-788-8246*
>



-- 
*Akshay Joshi*
*Principal Software Engineer *



*Phone: +91 20-3058-9517Mobile: +91 976-788-8246*


SSH_Error_Msg.patch
Description: Binary data

-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers