Browse code

Fix more compiler warnings.

Török Edvin authored on 2010/05/11 19:53:36
Showing 1 changed files
... ...
@@ -56,7 +56,7 @@ static	char	const	rcsid[] = "$Id: pdf.c,v 1.61 2007/02/12 20:46:09 njh Exp $";
56 56
  *Save the file being worked on in tmp */
57 57
 #endif
58 58
 
59
-static	int	asciihexdecode(const char *buf, off_t len, unsigned char *output);
59
+static	int	asciihexdecode(const char *buf, off_t len, char *output);
60 60
 static	int	ascii85decode(const char *buf, off_t len, unsigned char *output);
61 61
 static	const	char	*pdf_nextlinestart(const char *ptr, size_t len);
62 62
 static	const	char	*pdf_nextobject(const char *ptr, size_t len);
... ...
@@ -217,7 +217,7 @@ static int pdf_findobj(struct pdf_struct *pdf)
217 217
 }
218 218
 
219 219
 static int filter_writen(struct pdf_struct *pdf, struct pdf_obj *obj,
220
-			 int fout, const unsigned char *buf, off_t len, off_t *sum)
220
+			 int fout, const char *buf, off_t len, off_t *sum)
221 221
 {
222 222
     if (cli_checklimits("pdf", pdf->ctx, *sum, 0, 0))
223 223
 	return len; /* pretend it was a successful write to suppress CL_EWRITE */
... ...
@@ -226,19 +226,19 @@ static int filter_writen(struct pdf_struct *pdf, struct pdf_obj *obj,
226 226
 }
227 227
 
228 228
 static int filter_flatedecode(struct pdf_struct *pdf, struct pdf_obj *obj,
229
-			      const unsigned char *buf, off_t len, int fout, off_t *sum)
229
+			      const char *buf, off_t len, int fout, off_t *sum)
230 230
 {
231 231
     int zstat;
232 232
     z_stream stream;
233 233
     off_t nbytes;
234
-    unsigned char output[BUFSIZ];
234
+    char output[BUFSIZ];
235 235
 
236 236
     if (len == 0)
237 237
 	return CL_CLEAN;
238 238
     memset(&stream, 0, sizeof(stream));
239 239
     stream.next_in = (Bytef *)buf;
240 240
     stream.avail_in = len;
241
-    stream.next_out = output;
241
+    stream.next_out = (Bytef *)output;
242 242
     stream.avail_out = sizeof(output);
243 243
 
244 244
     zstat = inflateInit(&stream);
... ...
@@ -260,7 +260,7 @@ static int filter_flatedecode(struct pdf_struct *pdf, struct pdf_obj *obj,
260 260
 			return CL_EWRITE;
261 261
 		    }
262 262
 		    nbytes += written;
263
-		    stream.next_out = output;
263
+		    stream.next_out = (Bytef *)output;
264 264
 		    stream.avail_out = sizeof(output);
265 265
 		}
266 266
 		continue;
... ...
@@ -332,7 +332,7 @@ static int find_length(struct pdf_struct *pdf,
332 332
     start = pdf_nextobject(q, len);
333 333
     if (!start)
334 334
 	return 0;
335
-    len -= start - q;
335
+    /* len -= start - q; */
336 336
     q = start;
337 337
     length = atoi(q);
338 338
     while (isdigit(*q)) q++;
... ...
@@ -403,6 +403,7 @@ static int pdf_extract_obj(struct pdf_struct *pdf, struct pdf_obj *obj)
403 403
 			   pdf->size - obj->start,
404 404
 			   &p_stream, &p_endstream);
405 405
 	if (p_stream && p_endstream) {
406
+	    int rc2;
406 407
 	    const char *flate_in;
407 408
 	    long ascii_decoded_size = 0;
408 409
 	    size_t size = p_endstream - p_stream;
... ...
@@ -444,7 +445,7 @@ static int pdf_extract_obj(struct pdf_struct *pdf, struct pdf_obj *obj)
444 444
 		}
445 445
 		ascii_decoded_size = ascii85decode(start+p_stream,
446 446
 						   length,
447
-						   ascii_decoded);
447
+						   (unsigned char*)ascii_decoded);
448 448
 	    }
449 449
 	    if (ascii_decoded_size < 0) {
450 450
 		pdf->flags |= 1 << BAD_ASCIIDECODE;
... ...
@@ -468,7 +469,9 @@ static int pdf_extract_obj(struct pdf_struct *pdf, struct pdf_obj *obj)
468 468
 	     * */
469 469
 	    cli_dbgmsg("cli_pdf: extracted %ld bytes %u %u obj to %s\n", sum, obj->id>>8, obj->id&0xff, fullname);
470 470
 	    lseek(fout, 0, SEEK_SET);
471
-	    rc = cli_magic_scandesc(fout, pdf->ctx);
471
+	    rc2 = cli_magic_scandesc(fout, pdf->ctx);
472
+	    if (rc2 == CL_VIRUS || rc == CL_SUCCESS)
473
+		rc = rc2;
472 474
 	}
473 475
     } else if (obj->flags & (1 << OBJ_JAVASCRIPT)) {
474 476
 	const char *q2;
... ...
@@ -582,7 +585,7 @@ static struct pdfname_action pdfname_actions[] = {
582 582
 
583 583
 static void handle_pdfname(struct pdf_struct *pdf, struct pdf_obj *obj,
584 584
 			   const char *pdfname, int escapes,
585
-			   const char *after, enum objstate *state)
585
+			   enum objstate *state)
586 586
 {
587 587
     struct pdfname_action *act = NULL;
588 588
     unsigned j;
... ...
@@ -616,6 +619,8 @@ static void handle_pdfname(struct pdf_struct *pdf, struct pdf_obj *obj,
616 616
 	    case STATE_S:
617 617
 		*state = STATE_NONE;
618 618
 		break;
619
+	    default:
620
+		break;
619 621
 	}
620 622
     }
621 623
 }
... ...
@@ -690,7 +695,7 @@ static void pdf_parseobj(struct pdf_struct *pdf, struct pdf_obj *obj)
690 690
 	}
691 691
 	pdfname[i] = '\0';
692 692
 
693
-	handle_pdfname(pdf, obj, pdfname, escapes, q, &objstate);
693
+	handle_pdfname(pdf, obj, pdfname, escapes, &objstate);
694 694
 	if (objstate == STATE_JAVASCRIPT) {
695 695
 	    q2 = pdf_nextobject(q, dict_length);
696 696
 	    if (q2 && isdigit(*q2)) {
... ...
@@ -1431,7 +1436,7 @@ flatedecode(unsigned char *buf, off_t len, int fout, cli_ctx *ctx)
1431 1431
 }
1432 1432
 #endif
1433 1433
 
1434
-static int asciihexdecode(const char *buf, off_t len, unsigned char *output)
1434
+static int asciihexdecode(const char *buf, off_t len, char *output)
1435 1435
 {
1436 1436
     unsigned i,j;
1437 1437
     for (i=0,j=0;i<len;i++) {
... ...
@@ -1508,9 +1513,7 @@ ascii85decode(const char *buf, off_t len, unsigned char *output)
1508 1508
 				ret += quintet;
1509 1509
 				for(i = 0; i < quintet - 1; i++)
1510 1510
 					*output++ = (unsigned char)((sum >> (24 - 8 * i)) & 0xFF);
1511
-				quintet = 0;
1512 1511
 			}
1513
-			len = 0;
1514 1512
 			break;
1515 1513
 		} else if(!isspace(byte)) {
1516 1514
 			cli_dbgmsg("ascii85Decode: invalid character 0x%x, len %lu\n",