Browse code

don't make tmp_move negative (bb #772).

git-svn: trunk@3499

Török Edvin authored on 2008/01/13 18:37:43
Showing 2 changed files
... ...
@@ -1,3 +1,7 @@
1
+Sun Jan 13 11:09:18 EET 2008 (edwin)
2
+-----------------------------------
3
+ * libclamav/entconv.c: don't make tmp_move negative (bb #772).
4
+
1 5
 Sat Jan 12 23:00:17 EET 2008 (edwin)
2 6
 ------------------------------------
3 7
   * libclamav/Makefile.am/in, others.c: Fix build problem on OpenBSD: don't compile in
... ...
@@ -187,6 +187,7 @@ typedef struct {
187 187
 
188 188
 static iconv_t iconv_open(const char *tocode, const char* fromcode)
189 189
 {
190
+	cli_dbgmsg("Internal iconv\n");
190 191
 	iconv_t iconv = cli_malloc(sizeof(*iconv));
191 192
 	if(!iconv)
192 193
 		return NULL;
... ...
@@ -813,7 +814,7 @@ unsigned char* encoding_norm_readline(struct entity_conv* conv, FILE* stream_in,
813 813
 		return NULL;
814 814
 	else {
815 815
 		/* stream_in|in_m_area ->(read_raw) conv->tmp_area -> (iconv) conv->out_area -> (normalize) conv->norm_area -> (cli_readline) return value*/
816
-		const size_t tmp_move = conv->tmp_area.length - conv->tmp_area.offset;
816
+		const size_t tmp_move = conv->tmp_area.length >= conv->tmp_area.offset ? conv->tmp_area.length - conv->tmp_area.offset : 0;
817 817
 		const size_t tmp_available = conv->buffer_size - tmp_move;
818 818
 		const size_t max_read = maxlen < tmp_available ? maxlen : tmp_available;
819 819
 		unsigned char* tmpbuff = &conv->tmp_area.buffer[tmp_move];