diff options
author | Werner Koch <wk@gnupg.org> | 2006-12-06 11:16:50 +0100 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2006-12-06 11:16:50 +0100 |
commit | 0173cd5a9810622e38b76123528e83024fb59a0c (patch) | |
tree | b8c52436a3d30842f2c59cfcf273a7934432321f /g10/dearmor.c | |
parent | * keyedit.c (menu_clean): Show "already minimized" rather than (diff) | |
download | gnupg2-0173cd5a9810622e38b76123528e83024fb59a0c.tar.xz gnupg2-0173cd5a9810622e38b76123528e83024fb59a0c.zip |
Fixes for CVE-2006-6235
Diffstat (limited to 'g10/dearmor.c')
-rw-r--r-- | g10/dearmor.c | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/g10/dearmor.c b/g10/dearmor.c index ae89e8e58..23c3f7419 100644 --- a/g10/dearmor.c +++ b/g10/dearmor.c @@ -42,12 +42,12 @@ int dearmor_file( const char *fname ) { - armor_filter_context_t afx; + armor_filter_context_t *afx; IOBUF inp = NULL, out = NULL; int rc = 0; int c; - memset( &afx, 0, sizeof afx); + afx = new_armor_context (); /* prepare iobufs */ inp = iobuf_open(fname); @@ -64,23 +64,21 @@ dearmor_file( const char *fname ) goto leave; } - iobuf_push_filter( inp, armor_filter, &afx ); + push_armor_filter ( afx, inp ); if( (rc = open_outfile( fname, 0, &out )) ) goto leave; - - while( (c = iobuf_get(inp)) != -1 ) iobuf_put( out, c ); - leave: if( rc ) iobuf_cancel(out); else iobuf_close(out); iobuf_close(inp); + release_armor_context (afx); return rc; } @@ -91,12 +89,12 @@ dearmor_file( const char *fname ) int enarmor_file( const char *fname ) { - armor_filter_context_t afx; + armor_filter_context_t *afx; IOBUF inp = NULL, out = NULL; int rc = 0; int c; - memset( &afx, 0, sizeof afx); + afx = new_armor_context (); /* prepare iobufs */ inp = iobuf_open(fname); @@ -117,9 +115,9 @@ enarmor_file( const char *fname ) if( (rc = open_outfile( fname, 1, &out )) ) goto leave; - afx.what = 4; - afx.hdrlines = "Comment: Use \"gpg --dearmor\" for unpacking\n"; - iobuf_push_filter( out, armor_filter, &afx ); + afx->what = 4; + afx->hdrlines = "Comment: Use \"gpg --dearmor\" for unpacking\n"; + push_armor_filter ( afx, out ); while( (c = iobuf_get(inp)) != -1 ) iobuf_put( out, c ); @@ -131,6 +129,7 @@ enarmor_file( const char *fname ) else iobuf_close(out); iobuf_close(inp); + release_armor_context (afx); return rc; } |