[jd/f13/master] Patch (from rev 3850) to fix segv with long URL

Mamoru Tasaka mtasaka at fedoraproject.org
Thu Feb 17 18:26:17 UTC 2011


commit b0cba1db21cfe18bff3f68e51238ab9ff1ece24f
Author: Mamoru Tasaka <tasaka1 at localhost.localdomain>
Date:   Fri Feb 18 03:26:18 2011 +0900

    Patch (from rev 3850) to fix segv with long URL

 jd-rev3850-segv-with-long-URL.patch |   68 +++++++++++++++++++++++++++++++++++
 jd.spec                             |    5 +++
 2 files changed, 73 insertions(+), 0 deletions(-)
---
diff --git a/jd-rev3850-segv-with-long-URL.patch b/jd-rev3850-segv-with-long-URL.patch
new file mode 100644
index 0000000..18d7a56
--- /dev/null
+++ b/jd-rev3850-segv-with-long-URL.patch
@@ -0,0 +1,68 @@
+Index: src/dbtree/nodetreebase.cpp
+===================================================================
+--- src/dbtree/nodetreebase.cpp	(revision 3849)
++++ src/dbtree/nodetreebase.cpp	(revision 3850)
+@@ -2010,7 +2010,7 @@
+         // アンカーのチェック
+         int n_in = 0;
+         int n_out = 0;
+-        char tmpstr[ LNG_LINK ], tmplink[ LNG_LINK ];
++        char tmpstr[ LNG_LINK +16 ], tmplink[ LNG_LINK +16 ];
+         int lng_str = 0, lng_link = strlen( PROTO_ANCHORE );
+         ANCINFO ancinfo[ MAX_ANCINFO ];
+         int lng_anc = 0;
+@@ -2504,7 +2504,7 @@
+         }
+     }
+ 
+-    if( n_in + offset > lng_link ) return MISC::SCHEME_NONE;
++    if( n_in + offset >= lng_link ) return MISC::SCHEME_NONE;
+ 
+     if( ! url_encode ){
+         memcpy( str_link + offset, str_in, n_in );
+@@ -2513,19 +2513,32 @@
+     else{ // URLエンコードが必要な場合
+ 
+         char *pos = str_link + offset;
++        int tmp_out = offset;
+         for( int i = 0; i < n_in; ++i, ++pos ){
+ 
+             if( str_in[ i ] == '^' ){ // '^' -> %5e
+                 *( pos++ ) = '%';
+                 *( pos++ ) = '5';
+                 *pos = 'e';
++                tmp_out += 3;
+             }
+             else if( str_in[ i ] == '|' ){ // '|' -> %7c
+                 *( pos++ ) = '%';
+                 *( pos++ ) = '7';
+                 *pos = 'c';
++                tmp_out += 3;
+             }
+-            else *pos = str_in[ i ];
++            else{
++                *pos = str_in[ i ];
++                ++tmp_out;
++            }
++
++            if( tmp_out >= lng_link ){
++#ifdef _DEBUG
++                std::cout << " tmp_out = " << tmp_out << " lng_link = " << lng_link << " n_in + offset = " << n_in + offset << std::endl;
++#endif                
++                return MISC::SCHEME_NONE;
++            }
+         }
+         *pos = '\0';
+     }
+@@ -2537,6 +2550,11 @@
+         str_link[ 2 ] = 't';
+     }        
+ 
++#ifdef _DEBUG
++    std::cout << str_link << std::endl
++              << "len = " << strlen( str_link ) << " lng_link = " << lng_link << " n_in + offset = " << n_in + offset << std::endl;
++#endif
++
+     return linktype;
+ }
+ 
diff --git a/jd.spec b/jd.spec
index 23ed595..a328124 100644
--- a/jd.spec
+++ b/jd.spec
@@ -52,6 +52,7 @@ URL:            http://jd4linux.sourceforge.jp/
 Source0:        http://dl.sourceforge.jp/jd4linux/%{repoid}/%{name}-%{main_ver}-%{strtag}.tgz
 #Source0:	%{name}-%{main_ver}-%{strtag}.tgz
 Patch0:         jd-2.6.0-rc100130-env-pkg-distro-specific.patch
+Patch1:		jd-rev3850-segv-with-long-URL.patch
 BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 
 BuildRequires:  %{gtkmmdevel}
@@ -78,6 +79,7 @@ JD is a 2ch browser based on gtkmm2.
 %prep
 %setup -q -n %{name}-%{main_ver}-%{strtag}
 #find . -name .svn | sort -r | xargs %{__rm} -rf
+%patch1 -p0 -b .rev3850
 
 # Fedora specific
 if ( uname -n | grep -q 'fedoraproject\.org' ) ; then
@@ -141,6 +143,9 @@ gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
 %{icondir}/%{name}.png
 
 %changelog
+* Fri Feb 18 2011 Mamoru Tasaka <mtasaka at ioa.s.u-tokyo.ac.jp> - 2.8.1-0.3.beta110214
+- Patch (from rev 3850) to fix segv with long URL
+
 * Tue Feb 15 2011 Mamoru Tasaka <mtasaka at ioa.s.u-tokyo.ac.jp> - 2.8.1-0.2.beta110214
 - 2.8.1 beta 110214
 


More information about the scm-commits mailing list