Re: s2s whitelist problem

2012-08-02 Thread Eugene Agafonov
Here is a pull request with modified fix 
https://github.com/Jabberd2/jabberd2/pull/7

On Thursday, August 02, 2012 01:00:03 AM Clint Eastwood wrote:
 Hello,
 
 Two observations about the s2s whitelist feature:
 
 1 - I guess we should add a comment on the s2s.xml template file about the
 necessity of enable_whitelist/ tag. I had to look at the source code to
 figure out it was needed.
 
 2 - When the whitelist feature was enabled, s2s started to crash and
 generate core dumps. I digged into the code and used valgrind to get to the
 problem. Making this change worked for me:
 
 diff --git a/s2s/main.c b/s2s/main.c
 index 6a0ff8e..ffd54c4 100644
 --- a/s2s/main.c
 +++ b/s2s/main.c
 @@ -746,7 +746,7 @@ int s2s_domain_in_whitelist(s2s_t s2s, char *in_domain)
 {
  *dst = (char *)malloc(seg_tmp_len + 1);
  if (*dst != NULL) {
  strncpy(*dst, seg_tmp, seg_tmp_len + 1);
 -dst[seg_tmp_len] = '\0';
 +*(*dst + seg_tmp_len) = '\0';
  } else {
  if (seg_tmp != NULL) {
  free(seg_tmp);
 
 Comments, please !
 
 Regards




Re: s2s whitelist problem

2012-08-02 Thread Tomasz Sterna
Dnia 2012-08-02, czw o godzinie 13:03 +0400, Eugene Agafonov pisze:
 Here is a pull request with modified fix 
 https://github.com/Jabberd2/jabberd2/pull/7 

This is a more readable fix. Merged.

Thank you guys. :-)





s2s whitelist problem

2012-08-01 Thread Clint Eastwood
Hello,

Two observations about the s2s whitelist feature:

1 - I guess we should add a comment on the s2s.xml template file about the
necessity of enable_whitelist/ tag. I had to look at the source code to
figure out it was needed.

2 - When the whitelist feature was enabled, s2s started to crash and
generate core dumps. I digged into the code and used valgrind to get to the
problem. Making this change worked for me:

diff --git a/s2s/main.c b/s2s/main.c
index 6a0ff8e..ffd54c4 100644
--- a/s2s/main.c
+++ b/s2s/main.c
@@ -746,7 +746,7 @@ int s2s_domain_in_whitelist(s2s_t s2s, char *in_domain)
{
 *dst = (char *)malloc(seg_tmp_len + 1);
 if (*dst != NULL) {
 strncpy(*dst, seg_tmp, seg_tmp_len + 1);
-dst[seg_tmp_len] = '\0';
+*(*dst + seg_tmp_len) = '\0';
 } else {
 if (seg_tmp != NULL) {
 free(seg_tmp);

Comments, please !

Regards