2edfb0
From nobody Mon Sep 17 00:00:00 2001
2edfb0
From: Ben Feinstein <ben@audiun.com>
2edfb0
Date: Sat, 10 Jun 2006 20:59:13 +0400
2edfb0
Subject: [PATCH 7/8] Add extra debugging to ftpdu_verify()
2edfb0
2edfb0
---
2edfb0
2edfb0
 lib/ftdecode.c |   16 +++++++++++++---
2edfb0
 1 files changed, 13 insertions(+), 3 deletions(-)
2edfb0
2edfb0
6c73ed47b26944f97fa8d5cfed1719b8146c124a
2edfb0
diff --git a/lib/ftdecode.c b/lib/ftdecode.c
2edfb0
index ff6b0cf..8884db9 100644
2edfb0
--- a/lib/ftdecode.c
2edfb0
+++ b/lib/ftdecode.c
2edfb0
@@ -122,8 +122,10 @@ int ftpdu_verify(struct ftpdu *ftpdu)
2edfb0
   ret = -1;
2edfb0
 
2edfb0
   /* enough bytes to decode the count and version? */
2edfb0
-  if (ftpdu->bused < 4)
2edfb0
+  if (ftpdu->bused < 4) {
2edfb0
+    fterr_warnx("not enough bytes to decode the count and version.");
2edfb0
     goto ftpdu_verify_out_quick;
2edfb0
+  }
2edfb0
 
2edfb0
   ph = (struct ftpdu_header*)&ftpdu->buf;
2edfb0
 
2edfb0
@@ -158,15 +160,22 @@ #endif /* LITTLE_ENDIAN */
2edfb0
     case 5:
2edfb0
 
2edfb0
       /* max PDU's in record */
2edfb0
-      if (ph->count > FT_PDU_V5_MAXFLOWS)
2edfb0
+      if (ph->count > FT_PDU_V5_MAXFLOWS) {
2edfb0
+	fterr_warnx("too many pdus (%d) in record, max %d", ph->count,
2edfb0
+		FT_PDU_V5_MAXFLOWS);
2edfb0
         goto ftpdu_verify_out;
2edfb0
+      }
2edfb0
+
2edfb0
 
2edfb0
       size = offsetof(struct ftpdu_v5, records) +
2edfb0
              ph->count * sizeof (struct ftrec_v5);
2edfb0
 
2edfb0
       /* PDU received size == PDU expected size? */
2edfb0
-      if (size != ftpdu->bused)
2edfb0
+      if (size != ftpdu->bused) {
2edfb0
+        fterr_warnx("pdu received size was wrong.  expected %d got %d",
2edfb0
+                ftpdu->bused, size);
2edfb0
         goto ftpdu_verify_out;
2edfb0
+      }
2edfb0
 
2edfb0
       ftpdu->ftv.d_version = 5;
2edfb0
       ftpdu->decodef = fts3rec_pdu_v5_decode;
2edfb0
@@ -516,6 +525,7 @@ #endif /* LITTLE_ENDIAN */
2edfb0
       break; /* 8 */
2edfb0
 
2edfb0
       default:
2edfb0
+	  fterr_warnx("ftpdu version not set.");
2edfb0
           goto ftpdu_verify_out;
2edfb0
 
2edfb0
   } /* switch ph->version */
2edfb0
-- 
2edfb0
1.3.3
2edfb0