Changeset 72 for trunk/gtk


Ignore:
Timestamp:
Jan 30, 2006, 8:01:08 PM (16 years ago)
Author:
joshe
Message:

Validate that data read from prefs and state files is valid UTF-8.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gtk/conf.c

    r51 r72  
    171171      case G_IO_STATUS_NORMAL:
    172172        if(NULL != line) {
    173           if(NULL != (sep = strchr(line, PREF_SEP_KEYVAL)) && sep > line) {
     173          if(g_utf8_validate(line, len, NULL) &&
     174             NULL != (sep = strchr(line, PREF_SEP_KEYVAL)) && sep > line) {
    174175            *sep = '\0';
    175176            line[termpos] = '\0';
     
    333334      case G_IO_STATUS_NORMAL:
    334335        if(NULL != line) {
    335           ts = g_new0(struct cf_torrentstate, 1);
    336           ptr = line;
    337           while(NULL != (ptr = getstateval(ts, ptr)))
    338             ;
     336          if(g_utf8_validate(line, -1, NULL)) {
     337            ts = g_new0(struct cf_torrentstate, 1);
     338            ptr = line;
     339            while(NULL != (ptr = getstateval(ts, ptr)))
     340              ;
     341            if(NULL != ts->ts_torrent && NULL != ts->ts_directory)
     342              ret = g_list_append(ret, ts);
     343            else
     344              cf_freestate(ts);
     345          }
    339346          g_free(line);
    340           if(NULL != ts->ts_torrent && NULL != ts->ts_directory)
    341             ret = g_list_append(ret, ts);
    342           else
    343             cf_freestate(ts);
    344347        }
    345348        break;
     
    438441  io = g_io_channel_unix_new(fd);
    439442  g_io_channel_set_close_on_unref(io, TRUE);
    440 
    441   /* XXX what the hell should I be doing about unicode? */
    442443
    443444  err = NULL;
Note: See TracChangeset for help on using the changeset viewer.