You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tcl.apache.org by mx...@apache.org on 2019/01/15 09:39:05 UTC

[tcl-rivet] branch master updated (724be29 -> 714e7cb)

This is an automated email from the ASF dual-hosted git repository.

mxmanghi pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/tcl-rivet.git.


    from 724be29  fix broken links in manual pages
     new ac95e6d  several changes to resolve ambiguities in implicit casting int from and to size_t
     new 714e7cb  regenerated from rivet.xml.in

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 ChangeLog                             |  7 ++++
 doc/rivet.xml                         | 45 +++++++++++----------
 src/librivet/rivetList.c              |  4 +-
 src/mod_rivet_ng/TclWebapache.c       |  4 +-
 src/mod_rivet_ng/rivetCore.c          |  5 +--
 src/mod_rivet_ng/rivet_types.h        |  2 +-
 src/request/apache_multipart_buffer.c | 73 ++++++++++++++++++-----------------
 src/request/apache_multipart_buffer.h | 28 +++++++-------
 src/request/apache_request.c          | 46 ++++++++++++----------
 9 files changed, 115 insertions(+), 99 deletions(-)


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@tcl.apache.org
For additional commands, e-mail: commits-help@tcl.apache.org


[tcl-rivet] 01/02: several changes to resolve ambiguities in implicit casting int from and to size_t

Posted by mx...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mxmanghi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tcl-rivet.git

commit ac95e6d8a328d880581206155fc076453cacd7e6
Author: Massimo Manghi <mx...@apache.org>
AuthorDate: Mon Dec 17 01:11:13 2018 +0100

    several changes to resolve ambiguities in implicit casting int from and to size_t
---
 ChangeLog                             |  7 ++++
 src/librivet/rivetList.c              |  4 +-
 src/mod_rivet_ng/TclWebapache.c       |  4 +-
 src/mod_rivet_ng/rivetCore.c          |  5 +--
 src/mod_rivet_ng/rivet_types.h        |  2 +-
 src/request/apache_multipart_buffer.c | 73 ++++++++++++++++++-----------------
 src/request/apache_multipart_buffer.h | 28 +++++++-------
 src/request/apache_request.c          | 46 ++++++++++++----------
 8 files changed, 91 insertions(+), 78 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index d76c670..9e19fe4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -23,6 +23,13 @@
 2018-12-17 Georgios Petasis <pe...@apache.org>
     * Readme.md: Added a separate badge for winbuild branch.
 
+2018-12-17 Massimo Manghi <mx...@apache.org>
+	* src/request/apache_request.c,src/request/apache_multipart_buffer.[c|h]: 
+	explicit cast to int wherever needed by calls to Tcl_* functions and changed 
+	int to size_t wherever required 
+	* src/mod_rivet_ng/rivet_types.h,rivetCore.c: field 'size' in structure typed as size_t
+	* src/mod_rivet_ng/TclWebapache.c: argument to Tcl_ReadChars explicitly cast to int 
+
 2018-12-16 Georgios Petasis <pe...@apache.org>
     * Readme.md: Added a Markdown README file, which shows the build status
     from Appveyor, for Windows.
diff --git a/src/librivet/rivetList.c b/src/librivet/rivetList.c
index 4847acf..5884756 100644
--- a/src/librivet/rivetList.c
+++ b/src/librivet/rivetList.c
@@ -464,10 +464,10 @@ Rivet_CommaJoinObjCmd (notUsed, interp, objc, objv)
              * calculations right!
              */
 
-             Tcl_AppendToObj (resultPtr, strPtr, walkPtr - strPtr);
+             Tcl_AppendToObj (resultPtr, strPtr, (int)(walkPtr - strPtr));
              strPtr = walkPtr - 1;
         }
-        Tcl_AppendToObj (resultPtr, strPtr, walkPtr - strPtr);
+        Tcl_AppendToObj (resultPtr, strPtr, (int)(walkPtr - strPtr));
     }
     Tcl_AppendToObj (resultPtr, "\"", 1);
     return TCL_OK;
diff --git a/src/mod_rivet_ng/TclWebapache.c b/src/mod_rivet_ng/TclWebapache.c
index 0f3b1ec..12d2573 100644
--- a/src/mod_rivet_ng/TclWebapache.c
+++ b/src/mod_rivet_ng/TclWebapache.c
@@ -725,7 +725,7 @@ int TclWeb_UploadData(char *varname, Tcl_Obj *data, TclWebRequest *req)
 	}
 
 	/* Put data in a variable  */
-	Tcl_ReadChars(chan, data, ApacheUpload_size(req->upload), 0);
+	Tcl_ReadChars(chan, data, (int)ApacheUpload_size(req->upload), 0);
 	if (Tcl_Close(req->interp, chan) == TCL_ERROR) {
 	    return TCL_ERROR;
 	}
@@ -739,7 +739,7 @@ int TclWeb_UploadData(char *varname, Tcl_Obj *data, TclWebRequest *req)
 
 int TclWeb_UploadSize(Tcl_Obj *sz, TclWebRequest *req)
 {
-    Tcl_SetIntObj(sz, ApacheUpload_size(req->upload));
+    Tcl_SetIntObj(sz, (int)ApacheUpload_size(req->upload));
     return TCL_OK;
 }
 
diff --git a/src/mod_rivet_ng/rivetCore.c b/src/mod_rivet_ng/rivetCore.c
index 66cb9d8..2c871e9 100644
--- a/src/mod_rivet_ng/rivetCore.c
+++ b/src/mod_rivet_ng/rivetCore.c
@@ -151,7 +151,7 @@ TCL_CMD_HEADER( Rivet_MakeURL )
         {
             /* relative path */
             char* script_name = TclWeb_GetEnvVar (private,"SCRIPT_NAME");
-            int   script_name_l = strlen(script_name);
+            size_t script_name_l = strlen(script_name);
 
             // regardless the reason for a SCRIPT_NAME being undefined we
             // prevent a segfault and we revert the behavior of makeurl
@@ -1791,8 +1791,7 @@ TCL_CMD_HEADER( Rivet_LogErrorCmd )
     return TCL_OK;
 }
 
-#define TESTPANIC 0
-
+#undef TESTPANIC
 #ifdef TESTPANIC
 /*
  *----------------------------------------------------------------------
diff --git a/src/mod_rivet_ng/rivet_types.h b/src/mod_rivet_ng/rivet_types.h
index 25151c5..b8cda08 100644
--- a/src/mod_rivet_ng/rivet_types.h
+++ b/src/mod_rivet_ng/rivet_types.h
@@ -39,7 +39,7 @@ typedef struct _ApacheUpload {
     char*           tempname;
     apr_table_t*    info;
     apr_file_t*     fp;
-    long            size;
+    size_t          size;
     ApacheRequest*  req;
 } ApacheUpload;
 
diff --git a/src/request/apache_multipart_buffer.c b/src/request/apache_multipart_buffer.c
index 36be086..484b8f3 100644
--- a/src/request/apache_multipart_buffer.c
+++ b/src/request/apache_multipart_buffer.c
@@ -31,25 +31,25 @@
   if partial is true, partial matches are allowed at the end of the buffer.
   returns NULL if not found, or a pointer to the start of the first match.
 */
-void* my_memstr(char* haystack, int haystacklen, const char* needle,
-		int partial)
+void* my_memstr(char* haystack,int haystacklen,const char* needle,int partial)
 {
-    int needlen = strlen(needle);
+    size_t needlen = strlen(needle);
     int len = haystacklen;
     char *ptr = haystack;
 
     /* iterate through first character matches */
     while( (ptr = memchr(ptr, needle[0], len)) ) {
-	/* calculate length after match */
-	len = haystacklen - (ptr - (char *)haystack);
-
-	/* done if matches up to capacity of buffer */
-	if(memcmp(needle, ptr, needlen) == 0 &&
-	   (partial || len >= needlen))
-	    break;
-
-	/* next character */
-	ptr++; len--;
+		/* calculate length after match */
+		len = haystacklen - (int)(ptr - (char *)haystack);
+
+		/* done if matches up to capacity of buffer */
+		if(memcmp(needle, ptr, needlen) == 0 && (partial || len >= needlen))
+		{
+			break;
+		}
+		
+		/* next character */
+		ptr++; len--;
     }
 
     return ptr;
@@ -73,7 +73,7 @@ int fill_buffer(multipart_buffer *self)
     bytes_to_read = self->bufsize - self->bytes_in_buffer;
 
     if (bytes_to_read >= self->r->remaining) {
-        bytes_to_read = self->r->remaining - strlen(self->boundary);
+        bytes_to_read = (int)(self->r->remaining - (apr_off_t)strlen(self->boundary));
 #ifdef DEBUG
         ap_log_rerror(MPB_ERROR, "mozilla 0.97 hack: '%ld'", self->r->remaining);
 #endif
@@ -118,7 +118,7 @@ char* next_line(multipart_buffer *self)
 
 	/* bump the pointer */
 	self->buf_begin = ptr + 1;
-	self->bytes_in_buffer -= (self->buf_begin - line);
+	self->bytes_in_buffer -= (int)(self->buf_begin - line);
     }
 
     /* no LF found */
@@ -177,17 +177,18 @@ int find_boundary(multipart_buffer *self, char *boundary)
 /*********************** external functions *********************/
 
 /* create new multipart_buffer structure */
-multipart_buffer *multipart_buffer_new(char *boundary, long length, request_rec *r)
+multipart_buffer *multipart_buffer_new(char *boundary, apr_off_t length, request_rec *r)
 {
     multipart_buffer *self = (multipart_buffer *)
 	apr_pcalloc (r->pool, sizeof(multipart_buffer));
 
-    int minsize = strlen(boundary)+6;
+    size_t minsize = strlen(boundary)+6;
+
     if(minsize < FILLUNIT) minsize = FILLUNIT;
 
     self->r = r;
     self->buffer = (char *) apr_pcalloc(r->pool, minsize+1);
-    self->bufsize = minsize;
+    self->bufsize = (int)minsize;
     self->request_length = length;
     self->boundary = (char*) apr_pstrcat(r->pool, "--", boundary, NULL);
     self->boundary_next = (char*) apr_pstrcat(r->pool, "\n", self->boundary, NULL);
@@ -243,35 +244,35 @@ apr_table_t *multipart_buffer_headers(multipart_buffer *self)
 }
 
 /* read until a boundary condition */
-int multipart_buffer_read(multipart_buffer *self, char *buf, int bytes)
+size_t multipart_buffer_read(multipart_buffer *self, char *buf, size_t bytes)
 {
-    int len, max;
-    char *bound;
+	size_t 	max;
+    size_t 	len;
+    char*	bound;
 
     /* fill buffer if needed */
     if(bytes > self->bytes_in_buffer) fill_buffer(self);
 
     /* look for a potential boundary match, only read data up to that point */
-    if( (bound = my_memstr(self->buf_begin, self->bytes_in_buffer,
-			   self->boundary_next, 1)) ) {
-	max = bound - self->buf_begin;
-     } else {
-	max = self->bytes_in_buffer;
-     }
+    if( (bound = my_memstr(self->buf_begin, self->bytes_in_buffer, self->boundary_next, 1)) ) {
+		max = bound - self->buf_begin;
+    } else {
+		max = self->bytes_in_buffer;
+		}
     /* maximum number of bytes we are reading */
     len = max < bytes-1 ? max : bytes-1;
 
 
     /* if we read any data... */
-    if(len > 0) {
-	/* copy the data */
-	memcpy(buf, self->buf_begin, len);
-	buf[len] = 0;
-	if(bound && len > 0 && buf[len-1] == '\r') buf[--len] = 0;
-
-	/* update the buffer */
-	self->bytes_in_buffer -= len;
-	self->buf_begin += len;
+    if (len > 0) {
+		/* copy the data */
+		memcpy(buf, self->buf_begin, len);
+		buf[len] = 0;
+		if(bound && len > 0 && buf[len-1] == '\r') buf[--len] = 0;
+
+		/* update the buffer */
+		self->bytes_in_buffer -= (int)len;
+		self->buf_begin += len;
     }
 
 #ifdef DEBUG
diff --git a/src/request/apache_multipart_buffer.h b/src/request/apache_multipart_buffer.h
index 2237942..b899a46 100644
--- a/src/request/apache_multipart_buffer.h
+++ b/src/request/apache_multipart_buffer.h
@@ -30,27 +30,27 @@
 
 typedef struct _multipart_buffer {
     /* request info */
-    request_rec *r;
-    long request_length;
+    request_rec*		r;
+    apr_off_t 			request_length;
 
     /* read buffer */
-    char *buffer;
-    char *buf_begin;
-    int  bufsize;
-    int  bytes_in_buffer;
+    char*				buffer;
+    char*				buf_begin;
+    int  				bufsize;
+    int  				bytes_in_buffer;
 
     /* boundary info */
-    char *boundary;
-    char *boundary_next;
-    char *boundary_end;
+    char*				boundary;
+    char*				boundary_next;
+    char*				boundary_end;
 } multipart_buffer;
 
-multipart_buffer	*multipart_buffer_new(char *boundary, long length, request_rec *r);
+multipart_buffer*	multipart_buffer_new(char* boundary,apr_off_t length,request_rec* r);
 ///*table*/apr_table_t	*multipart_buffer_headers(multipart_buffer *self);
-int			multipart_buffer_read(multipart_buffer *self, char *buf, int bytes);
-char			*multipart_buffer_read_body(multipart_buffer *self); 
-apr_table_t		*multipart_buffer_headers(multipart_buffer *self);
-int			multipart_buffer_eof(multipart_buffer *self);
+size_t				multipart_buffer_read(multipart_buffer* self,char* buf,size_t bytes);
+char*				multipart_buffer_read_body(multipart_buffer *self); 
+apr_table_t*		multipart_buffer_headers(multipart_buffer *self);
+int					multipart_buffer_eof(multipart_buffer *self);
 
 #ifdef __cplusplus
  }
diff --git a/src/request/apache_request.c b/src/request/apache_request.c
index b5f36f9..b370273 100644
--- a/src/request/apache_request.c
+++ b/src/request/apache_request.c
@@ -42,9 +42,12 @@ util_read(ApacheRequest *req, const char **rbuf)
 
     if (ap_should_client_block(r)) {
         char buff[HUGE_STRING_LEN];
-        int rsize, len_read, rpos=0;
-        long length = r->remaining;
+        int  len_read;
+		apr_off_t rpos;
+		apr_off_t rsize;
+        apr_off_t length = r->remaining;
 
+		rpos = 0;
         if (length > req->post_max && req->post_max > 0) {
             ap_log_rerror(REQ_ERROR,"entity too large (%d, max=%d)",
 					(int)length, req->post_max);
@@ -509,14 +512,14 @@ apr_file_t *ApacheRequest_tmpfile(ApacheRequest *req, ApacheUpload *upload)
 int
 ApacheRequest_parse_multipart(ApacheRequest *req,const char* ct)
 {
-    request_rec 	*r = req->r;
-    int 		rc = OK;
-    long 		length;
-    char 		*boundary;
-    multipart_buffer 	*mbuff;
-    ApacheUpload 	*upload = NULL;
-    apr_status_t  	status;
-    char 		error[1024];
+    request_rec*       r = req->r;
+    int                rc = OK;
+    apr_off_t          length;
+    char*              boundary;
+    multipart_buffer*  mbuff;
+    ApacheUpload*      upload = NULL;
+    apr_status_t       status;
+    char               error[1024];
 
     if ((rc = ap_setup_client_block(r, REQUEST_CHUNKED_ERROR))) {
         return rc;
@@ -533,7 +536,7 @@ ApacheRequest_parse_multipart(ApacheRequest *req,const char* ct)
     }
 
     do {
-        int blen;
+        size_t blen;
         boundary = ap_getword(r->pool, &ct, '=');
         if (boundary == NULL)
             return DECLINED;
@@ -550,10 +553,12 @@ ApacheRequest_parse_multipart(ApacheRequest *req,const char* ct)
     }
 
     while (!multipart_buffer_eof(mbuff)) {
-        apr_table_t *header = (apr_table_t*) multipart_buffer_headers(mbuff);
-        const char *cd, *param=NULL, *filename=NULL;
-        char buff[FILLUNIT];
-        int blen;
+        apr_table_t* 	header = (apr_table_t*) multipart_buffer_headers(mbuff);
+        const char*		cd;
+		const char*  	param = NULL;
+		const char*		filename=NULL;
+        char 			buff[FILLUNIT];
+        size_t 			blen;
 
         if (!header) {
 #ifdef DEBUG
@@ -625,12 +630,13 @@ ApacheRequest_parse_multipart(ApacheRequest *req,const char* ct)
             }
 
             while ((blen = multipart_buffer_read(mbuff, buff, sizeof(buff)))) {
-		apr_size_t bytes_to_write = (apr_size_t) blen;
-		status = apr_file_write(upload->fp,buff,&bytes_to_write);
-		if (status != 0) {
-		    apr_strerror(status,error,1024); 
+				apr_size_t bytes_to_write = (apr_size_t) blen;
+				status = apr_file_write(upload->fp,buff,&bytes_to_write);
+				
+				if (status != 0) {
+					apr_strerror(status,error,1024); 
                     return HTTP_INTERNAL_SERVER_ERROR;
-		}
+				}
                 upload->size += blen;
             }
         }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@tcl.apache.org
For additional commands, e-mail: commits-help@tcl.apache.org


[tcl-rivet] 02/02: regenerated from rivet.xml.in

Posted by mx...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mxmanghi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tcl-rivet.git

commit 714e7cb2d76a97e13be7bad13c58fb9b8b0a6b52
Author: Massimo Manghi <mx...@apache.org>
AuthorDate: Tue Jan 15 10:38:45 2019 +0100

    regenerated from rivet.xml.in
---
 doc/rivet.xml | 45 ++++++++++++++++++++++++---------------------
 1 file changed, 24 insertions(+), 21 deletions(-)

diff --git a/doc/rivet.xml b/doc/rivet.xml
index 89f940f..3022a6b 100644
--- a/doc/rivet.xml
+++ b/doc/rivet.xml
@@ -35,40 +35,43 @@
     <!ENTITY asciiglyphs.xml       SYSTEM "xml/asciiglyphs.xml" >
     <!ENTITY lazybridge.xml        SYSTEM "xml/lazybridge.xml" >
     <!ENTITY formbroker.xml        SYSTEM "xml/formbroker.xml" >
-    <!ENTITY version	           "3.2" >
+    <!ENTITY version	           	  "3.2" >
     <!ENTITY fullversion           "3.2.0" >
-    <!ENTITY version2-series	   "2.0,2.1,2.2,2.3" >
-    <!ENTITY version2-generic	   "2.x" >
-    <!ENTITY version30		       "3.0" >
-    <!ENTITY version31		       "3.1" >
+    <!ENTITY version2-series	     "2.0,2.1,2.2,2.3" >
+    <!ENTITY version2-generic	     "2.x" >
+    <!ENTITY version30		        "3.0" >
+    <!ENTITY version31		        "3.1" >
     <!ENTITY tcltk-url             "http://www.tcl.tk/" >
     <!ENTITY apache-url            "http://httpd.apache.org" >
+    <!ENTITY apache-apr            "http://apr.apache.org/" >
+    <!ENTITY apache-apreq          "http://httpd.apache.org/apreq/" >
+    <!ENTITY rivet-download        "http://tcl.apache.org/rivet/html/download.html" >
     <!ENTITY apachedoc-vhost       "https://httpd.apache.org/docs/2.4/vhosts" >
-    <!ENTITY apachedoc-mpm	       "https://httpd.apache.org/docs/2.4/mpm.html" >
-    <!ENTITY apachedoc-prefork	   "https://httpd.apache.org/docs/2.4/mod/prefork.html" >
-    <!ENTITY apachedoc-worker	   "https://httpd.apache.org/docs/2.4/mod/worker.html" >
-    <!ENTITY apachedoc-event	   "https://httpd.apache.org/docs/2.4/mod/event.html" >
-    <!ENTITY apachedoc-winnt	   "https://httpd.apache.org/docs/2.4/mod/mpm_winnt.html" >
+    <!ENTITY apachedoc-mpm	        "https://httpd.apache.org/docs/2.4/mpm.html" >
+    <!ENTITY apachedoc-prefork	  "https://httpd.apache.org/docs/2.4/mod/prefork.html" >
+    <!ENTITY apachedoc-worker	     "https://httpd.apache.org/docs/2.4/mod/worker.html" >
+    <!ENTITY apachedoc-event	     "https://httpd.apache.org/docs/2.4/mod/event.html" >
+    <!ENTITY apachedoc-winnt	     "https://httpd.apache.org/docs/2.4/mod/mpm_winnt.html" >
     <!ENTITY apachedoc-docroot     "https://httpd.apache.org/docs/2.4/mod/core.html#documentroot" >
-    <!ENTITY apachedoc-alias	   "https://httpd.apache.org/docs/2.4/mod/mod_alias.html" >
+    <!ENTITY apachedoc-alias	     "https://httpd.apache.org/docs/2.4/mod/mod_alias.html" >
     <!ENTITY apachedoc-rewrite     "https://httpd.apache.org/docs/2.4/mod/mod_rewrite.html" >
     <!ENTITY apachedoc-perftuning  "https://httpd.apache.org/docs/2.4/misc/perf-tuning.html" >
 ]>
 
 <!--
-   Copyright 2002-2005 The Apache Software Foundation
+	Copyright 2002-2019 The Apache Tcl Team
 
-   Licensed under the Apache License, Version 2.0 (the "License"); you
-   may not use this file except in compliance with the License.  You
-   may obtain a copy of the License at
+	Licensed under the Apache License, Version 2.0 (the "License");
+	you may not use this file except in compliance with the License.
+	You may obtain a copy of the License at
 
-   	http://www.apache.org/licenses/LICENSE-2.0
+	    http://www.apache.org/licenses/LICENSE-2.0
 
-   Unless required by applicable law or agreed to in writing, software
-   distributed under the License is distributed on an "AS IS" BASIS,
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
-   implied.  See the License for the specific language governing
-   permissions and limitations under the License.
+	Unless required by applicable law or agreed to in writing, software
+	distributed under the License is distributed on an "AS IS" BASIS,
+	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+	See the License for the specific language governing permissions and
+	limitations under the License.
 -->
 
 <article>


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@tcl.apache.org
For additional commands, e-mail: commits-help@tcl.apache.org