Re: svn commit: r1607278 - /tomcat/native/trunk/native/src/ssl.c

2014-07-02 Thread Mark Thomas
On 02/07/2014 21:25, Caldarale, Charles R wrote:
>> From: Mark Thomas [mailto:ma...@apache.org] 
>> Subject: Re: svn commit: r1607278 - /tomcat/native/trunk/native/src/ssl.c
> 
>> I need to brush up on my C to get my head around why, but this commit
>> has broken the build.
> 
>> Modified: tomcat/native/trunk/native/src/ssl.c
>> URL: 
>> http://svn.apache.org/viewvc/tomcat/native/trunk/native/src/ssl.c?rev=1607278&r1=1607277&r2=1607278&view=diff
>> ==
>> --- tomcat/native/trunk/native/src/ssl.c (original)
>> +++ tomcat/native/trunk/native/src/ssl.c Wed Jul  2 08:19:21 2014
>> @@ -871,8 +871,8 @@ static int jbs_write(BIO *b, const char 
>>  if (b->init && in != NULL) {
>>  BIO_JAVA *j = (BIO_JAVA *)b->ptr;
>>  JNIEnv   *e = NULL;
>> -jbyteArray jb = (*e)->NewByteArray(e, inl);
>>  tcn_get_java_env(&e);
>> +jbyteArray jb = (*e)->NewByteArray(e, inl);
>>  if (!(*e)->ExceptionOccurred(e)) {
>>  (*e)->SetByteArrayRegion(e, jb, 0, inl, (jbyte *)in);
>>  ret = (*e)->CallIntMethod(e, j->cb.obj,
>> @@ -890,8 +890,8 @@ static int jbs_read(BIO *b, char *out, i
>>  if (b->init && out != NULL) {
>>  BIO_JAVA *j = (BIO_JAVA *)b->ptr;
>>  JNIEnv   *e = NULL;
>> -jbyteArray jb = (*e)->NewByteArray(e, outl);
>>  tcn_get_java_env(&e);
>> +jbyteArray jb = (*e)->NewByteArray(e, outl);
>>  if (!(*e)->ExceptionOccurred(e)) {
>>  ret = (*e)->CallIntMethod(e, j->cb.obj,
>>j->cb.mid[1], jb);
> 
> This is C, not C++, so the declaration for jb must come before any 
> non-declaration statements within the block:
> 
>BIO_JAVA *j = (BIO_JAVA *)b->ptr;
>JNIEnv   *e = NULL;
>jbyteArray jb;
>tcn_get_java_env(&e);
>jb = (*e)->NewByteArray(e, inl);

Thank you! The next time you make it to an Apache event I'm at, I owe
you a beverage of your choice.

Mark


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



RE: svn commit: r1607278 - /tomcat/native/trunk/native/src/ssl.c

2014-07-02 Thread Caldarale, Charles R
> From: Mark Thomas [mailto:ma...@apache.org] 
> Subject: Re: svn commit: r1607278 - /tomcat/native/trunk/native/src/ssl.c

> I need to brush up on my C to get my head around why, but this commit
> has broken the build.

> Modified: tomcat/native/trunk/native/src/ssl.c
> URL: 
> http://svn.apache.org/viewvc/tomcat/native/trunk/native/src/ssl.c?rev=1607278&r1=1607277&r2=1607278&view=diff
> ==
> --- tomcat/native/trunk/native/src/ssl.c (original)
> +++ tomcat/native/trunk/native/src/ssl.c Wed Jul  2 08:19:21 2014
> @@ -871,8 +871,8 @@ static int jbs_write(BIO *b, const char 
>  if (b->init && in != NULL) {
>  BIO_JAVA *j = (BIO_JAVA *)b->ptr;
>  JNIEnv   *e = NULL;
> -jbyteArray jb = (*e)->NewByteArray(e, inl);
>  tcn_get_java_env(&e);
> +jbyteArray jb = (*e)->NewByteArray(e, inl);
>  if (!(*e)->ExceptionOccurred(e)) {
>  (*e)->SetByteArrayRegion(e, jb, 0, inl, (jbyte *)in);
>  ret = (*e)->CallIntMethod(e, j->cb.obj,
> @@ -890,8 +890,8 @@ static int jbs_read(BIO *b, char *out, i
>  if (b->init && out != NULL) {
>  BIO_JAVA *j = (BIO_JAVA *)b->ptr;
>  JNIEnv   *e = NULL;
> -jbyteArray jb = (*e)->NewByteArray(e, outl);
>  tcn_get_java_env(&e);
> +jbyteArray jb = (*e)->NewByteArray(e, outl);
>  if (!(*e)->ExceptionOccurred(e)) {
>  ret = (*e)->CallIntMethod(e, j->cb.obj,
>j->cb.mid[1], jb);

This is C, not C++, so the declaration for jb must come before any 
non-declaration statements within the block:

   BIO_JAVA *j = (BIO_JAVA *)b->ptr;
   JNIEnv   *e = NULL;
   jbyteArray jb;
   tcn_get_java_env(&e);
   jb = (*e)->NewByteArray(e, inl);

 - Chuck


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



Re: svn commit: r1607278 - /tomcat/native/trunk/native/src/ssl.c

2014-07-02 Thread Mark Thomas
On 02/07/2014 09:19, kkoli...@apache.org wrote:
> Author: kkolinko
> Date: Wed Jul  2 08:19:21 2014
> New Revision: 1607278
> 
> URL: http://svn.apache.org/r1607278
> Log:
> For https://issues.apache.org/bugzilla/show_bug.cgi?id=55938
> Fix "Dereference of null pointer" issues identified by clang, in "jbs_read", 
> "jbs_write".
> Not tested, but an obvious fix.

I need to brush up on my C to get my head around why, but this commit
has broken the build.

Complete error text follows:

cl -c -nologo -DWIN32 -D_WIN32 -D_WINDOWS -DWINNT -D_WINNT
-D_WIN32_WINNT=0x0501 -DWINVER=0x0501 -D_WIN32_IE=0x0600 -W3 -EHsc
-D_MBCS -DMBCS -D_X86_=1 -
O2 -Ob2 -Oy- -Zi -DNDEBUG -D_MT -MD -DAPR_DECLARE_STATIC -DZLIB_WINAPI
-DNO_IDEA -DNO_RC5 -DNO_MDC2 -DOPENSSL_NO_IDEA  -DOPENSSL_NO_RC5
-DOPENSSL_NO_MDC2 -DHAVE
_OPENSSL -DHAVE_SSL_SET_STATE=1 -I.\include -I
"\java\jdk1.7.0_60_x64\include" -I "\java\jdk1.7.0_60_x64\include\win32"
-IC:\deps-x86\apr-1.4.8\include -IC:\dep
s-x86\apr-1.4.8\include\arch\win32 -IC:\deps-x86\openssl-1.0.1h\include
-FoWINXP_X86_DLL_RELEASE\ -FdWINXP_X86_DLL_RELEASE\tcnative-1-src
.\src\ssl.c
ssl.c
.\src\ssl.c(888) : error C2275: 'jbyteArray' : illegal use of this type
as an expression
C:\java\jdk1.7.0_60_x64\include\jni.h(107) : see declaration of
'jbyteArray'
.\src\ssl.c(888) : error C2146: syntax error : missing ';' before
identifier 'jb'
.\src\ssl.c(888) : error C2065: 'jb' : undeclared identifier
.\src\ssl.c(888) : warning C4047: '=' : 'int' differs in levels of
indirection from 'jbyteArray'
.\src\ssl.c(890) : error C2065: 'jb' : undeclared identifier
.\src\ssl.c(890) : warning C4047: 'function' : 'jbyteArray' differs in
levels of indirection from 'int'
.\src\ssl.c(890) : warning C4024: 'function through pointer' : different
types for formal and actual parameter 2
.\src\ssl.c(892) : error C2065: 'jb' : undeclared identifier
.\src\ssl.c(893) : error C2065: 'jb' : undeclared identifier
.\src\ssl.c(893) : warning C4047: 'function' : 'jbyteArray' differs in
levels of indirection from 'int'
.\src\ssl.c(893) : warning C4024: 'function through pointer' : different
types for formal and actual parameter 2
.\src\ssl.c(894) : error C2065: 'jb' : undeclared identifier
.\src\ssl.c(894) : warning C4047: 'function' : 'jobject' differs in
levels of indirection from 'int'
.\src\ssl.c(894) : warning C4024: 'function through pointer' : different
types for formal and actual parameter 2
.\src\ssl.c(907) : error C2275: 'jbyteArray' : illegal use of this type
as an expression
C:\java\jdk1.7.0_60_x64\include\jni.h(107) : see declaration of
'jbyteArray'
.\src\ssl.c(907) : error C2146: syntax error : missing ';' before
identifier 'jb'
.\src\ssl.c(907) : error C2065: 'jb' : undeclared identifier
.\src\ssl.c(907) : warning C4047: '=' : 'int' differs in levels of
indirection from 'jbyteArray'
.\src\ssl.c(910) : error C2065: 'jb' : undeclared identifier
.\src\ssl.c(912) : error C2065: 'jb' : undeclared identifier
.\src\ssl.c(912) : warning C4047: 'function' : 'jarray' differs in
levels of indirection from 'int'
.\src\ssl.c(912) : warning C4024: 'function through pointer' : different
types for formal and actual parameter 2
.\src\ssl.c(914) : error C2065: 'jb' : undeclared identifier
.\src\ssl.c(914) : warning C4047: 'function' : 'jarray' differs in
levels of indirection from 'int'
.\src\ssl.c(914) : warning C4024: 'function through pointer' : different
types for formal and actual parameter 2
.\src\ssl.c(916) : error C2065: 'jb' : undeclared identifier
.\src\ssl.c(916) : warning C4047: 'function' : 'jobject' differs in
levels of indirection from 'int'
.\src\ssl.c(916) : warning C4024: 'function through pointer' : different
types for formal and actual parameter 2
NMAKE : fatal error U1077: 'c:\cmsc\msvc\bin\i386\cl.EXE' : return code
'0x2'
Stop.

> 
> Modified:
> tomcat/native/trunk/native/src/ssl.c
> 
> Modified: tomcat/native/trunk/native/src/ssl.c
> URL: 
> http://svn.apache.org/viewvc/tomcat/native/trunk/native/src/ssl.c?rev=1607278&r1=1607277&r2=1607278&view=diff
> ==
> --- tomcat/native/trunk/native/src/ssl.c (original)
> +++ tomcat/native/trunk/native/src/ssl.c Wed Jul  2 08:19:21 2014
> @@ -871,8 +871,8 @@ static int jbs_write(BIO *b, const char 
>  if (b->init && in != NULL) {
>  BIO_JAVA *j = (BIO_JAVA *)b->ptr;
>  JNIEnv   *e = NULL;
> -jbyteArray jb = (*e)->NewByteArray(e, inl);
>  tcn_get_java_env(&e);
> +jbyteArray jb = (*e)->NewByteArray(e, inl);
>  if (!(*e)->ExceptionOccurred(e)) {
>  (*e)->SetByteArrayRegion(e, jb, 0, inl, (jbyte *)in);
>  ret = (*e)->CallIntMethod(e, j->cb.obj,
> @@ -890,8 +890,8 @@ static int jbs_read(BIO *b, char *out, i
>  if (b->init && out != NULL) {
>  BIO_JAVA *j = (BIO_JAVA *)b->ptr;
>  JNIEnv   *e = NULL;
> -jbyteArray jb = (*e)->NewByteArray(e, outl);
>  tcn_get_java_env(&e