mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +02:00
Check for garbled packets
This commit is contained in:
parent
6c09d0f462
commit
e46ad749f9
9 changed files with 155 additions and 28 deletions
|
@ -182,7 +182,7 @@ void
|
|||
print_string( FILE *fp, const byte *p, size_t n, int delim )
|
||||
{
|
||||
for( ; n; n--, p++ )
|
||||
if( iscntrl( *p ) || *p == delim ) {
|
||||
if( *p < 0x20 || (*p >= 0x7f && *p < 0xa0) || *p == delim ) {
|
||||
putc('\\', fp);
|
||||
if( *p == '\n' )
|
||||
putc('n', fp);
|
||||
|
@ -239,7 +239,7 @@ make_printable_string( const byte *p, size_t n, int delim )
|
|||
|
||||
/* first count length */
|
||||
for(save_n = n, save_p = p, buflen=1 ; n; n--, p++ ) {
|
||||
if( iscntrl( *p ) || *p == delim ) {
|
||||
if( *p < 0x20 || (*p >= 0x7f && *p < 0xa0) || *p == delim ) {
|
||||
if( *p=='\n' || *p=='\r' || *p=='\f'
|
||||
|| *p=='\v' || *p=='\b' || !*p )
|
||||
buflen += 2;
|
||||
|
@ -254,7 +254,7 @@ make_printable_string( const byte *p, size_t n, int delim )
|
|||
/* and now make the string */
|
||||
d = buffer = m_alloc( buflen );
|
||||
for( ; n; n--, p++ ) {
|
||||
if( iscntrl( *p ) || *p == delim ) {
|
||||
if( *p < 0x20 || (*p >= 0x7f && *p < 0xa0) || *p == delim ) {
|
||||
*d++ = '\\';
|
||||
if( *p == '\n' )
|
||||
*d++ = 'n';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue