See ChangeLog: Wed Sep 15 16:22:17 CEST 1999 Werner Koch
[gnupg.git] / g10 / free-packet.c
index aef8e2f..0a61e22 100644 (file)
@@ -229,7 +229,7 @@ free_compressed( PKT_compressed *zd )
     if( zd->buf ) { /* have to skip some bytes */
        /* don't have any information about the length, so
         * we assume this is the last packet */
-       while( iobuf_get(zd->buf) != -1 )
+       while( iobuf_read( zd->buf, NULL, 1<<30 ) != -1 )
            ;
     }
     m_free(zd);
@@ -240,12 +240,17 @@ free_encrypted( PKT_encrypted *ed )
 {
     if( ed->buf ) { /* have to skip some bytes */
        if( iobuf_in_block_mode(ed->buf) ) {
-           while( iobuf_get(ed->buf) != -1 )
+           while( iobuf_read( ed->buf, NULL, 1<<30 ) != -1 )
                ;
        }
        else {
-           for( ; ed->len; ed->len-- ) /* skip the packet */
-               iobuf_get(ed->buf);
+          while( ed->len ) { /* skip the packet */
+              int n = iobuf_read( ed->buf, NULL, ed->len );
+              if( n == -1 )
+                  ed->len = 0;
+              else
+                  ed->len -= n;
+          }
        }
     }
     m_free(ed);
@@ -257,12 +262,17 @@ free_plaintext( PKT_plaintext *pt )
 {
     if( pt->buf ) { /* have to skip some bytes */
        if( iobuf_in_block_mode(pt->buf) ) {
-           while( iobuf_get(pt->buf) != -1 )
+           while( iobuf_read( pt->buf, NULL, 1<<30 ) != -1 )
                ;
        }
        else {
-           for( ; pt->len; pt->len-- ) /* skip the packet */
-               iobuf_get(pt->buf);
+          while( pt->len ) { /* skip the packet */
+              int n = iobuf_read( pt->buf, NULL, pt->len );
+              if( n == -1 )
+                  pt->len = 0;
+              else
+                  pt->len -= n;
+          }
        }
     }
     m_free(pt);