Changeset 33b306e


Ignore:
Timestamp:
2010-04-07T02:27:55Z (15 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
d4efddf
Parents:
7815a2b
Message:

Don't allow non-8-bit character sets like utf-16 which completely break the
IRC protocol. (Happened to at least two public server users by now and it
renders the accounts useless without manual intervention.)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • irc.c

    r7815a2b r33b306e  
    5252{
    5353        irc_t *irc = set->data;
     54        char *test;
     55        gsize test_bytes = 0;
    5456        GIConv ic, oc;
    5557
     
    5759                value = g_strdup( "utf-8" );
    5860
     61        if( ( oc = g_iconv_open( value, "utf-8" ) ) == (GIConv) -1 )
     62        {
     63                return NULL;
     64        }
     65        if( ( test = g_convert_with_iconv( " ", 1, oc, NULL, &test_bytes, NULL ) ) == NULL ||
     66            test_bytes > 1 )
     67        {
     68                g_free( test );
     69                g_iconv_close( oc );
     70                irc_usermsg( irc, "Unsupported character set: The IRC protocol "
     71                                  "only supports 8-bit character sets." );
     72                return NULL;
     73        }
    5974        if( ( ic = g_iconv_open( "utf-8", value ) ) == (GIConv) -1 )
    6075        {
    61                 return NULL;
    62         }
    63         if( ( oc = g_iconv_open( value, "utf-8" ) ) == (GIConv) -1 )
    64         {
    65                 g_iconv_close( ic );
     76                g_iconv_close( oc );
    6677                return NULL;
    6778        }
Note: See TracChangeset for help on using the changeset viewer.