Text  |   XML   |   Visible Warnings:

irssi-0.8.14 : irssi-0.8.14 analysis 2 : Null Pointer Dereference  at fe-channels.c:439

Categories: LANG.MEM.NPD CWE:476
Warning ID: 7296.28385
Procedure: display_sorted_nicks
Trace: view
Modified: Thu Nov 26 11:09:14 2009   show details
 
Priority: None
State: None
Finding: None
Owner: None
  edit properties

Legend [ X ]
Warning Location
Contributes
Parse Error
Other Warning
Two or More Loop Iterations
On Execution Path
Comment
Macro
Preprocessor
Include
Keyword
Preprocessed Away

Source  |  Language: C Hide Legend     
ProblemLineSource
   /kat0/fletcher/SATE/2010/irssi-0.8.14/src/fe-common/core/fe-channels.c
   Enter display_sorted_nicks
 328 static void display_sorted_nicks(CHANNEL_REC *channel, GSList *nicklist) 
 329 {
 330         WINDOW_REC *window;
 331         TEXT_DEST_REC dest;
 332         GString *str;
 333         GSList *tmp;
 334         char *format, *stripped, *prefix_format;
 335         char *linebuf, nickmode[2] = { 0, 0 };
 336         int *columns, cols, rows, last_col_rows, col, row, max_width;
 337         int item_extra, linebuf_size, formatnum;
 338  
 339         window = window_find_closest(channel->server, channel->visible_name,
 340                                      MSGLEVEL_CLIENTCRAP);
 341         max_width = window->width;
 342  
 343         /* get the length of item extra stuff ("[ ] ") */ 
 344         format = format_get_text(MODULE_NAME, NULL,
 345                                  channel->server, channel->visible_name,
 346                                  TXT_NAMES_NICK, " ", "");
 347         stripped = strip_codes(format);
 348         item_extra = strlen(stripped);
 349         g_free(stripped);
 350         g_free(format);
 351  
 352         if (settings_get_int("names_max_width") > 0 &&
 353             settings_get_int("names_max_width") < max_width)
 354                 max_width = settings_get_int("names_max_width");
 355  
 356         /* remove width of the timestamp from max_width */ 
 357         format_create_dest(&dest, channel->server, channel->visible_name,
 358                            MSGLEVEL_CLIENTCRAP, NULL);
 359         format = format_get_line_start(current_theme, &dest, time(NULL));
 360         if (format != NULL) {
 361                 stripped = strip_codes(format);
 362                 max_width -= strlen(stripped);
 363                 g_free(stripped);
 364                 g_free(format);
 365         }
 366  
 367         /* remove width of the prefix from max_width */ 
 368         prefix_format = format_get_text(MODULE_NAME, NULL,
 369                                         channel->server, channel->visible_name,
 370                                         TXT_NAMES_PREFIX,
 371                                         channel->visible_name);
 372         if (prefix_format != NULL) {
 373                 stripped = strip_codes(prefix_format);
 374                 max_width -= strlen(stripped);
 375                 g_free(stripped);
 376         }
 377  
 378         if (max_width <= 0) {
 379                 /* we should always have at least some space .. if we 
 380                    really don't, it won't show properly anyway. */ 
 381                 max_width = 10;
 382         }
 383  
 384         /* calculate columns */ 
 385         cols = get_max_column_count(nicklist, get_nick_length, max_width,
 386                                     settings_get_int("names_max_columns"),
 387                                     item_extra, 3, &columns, &rows);
 388         nicklist = columns_sort_list(nicklist, rows);
 389  
 390         /* rows in last column */ 
 391         last_col_rows = rows-(cols*rows-g_slist_length(nicklist));
 392         if (last_col_rows == 0)
 393                 last_col_rows = rows;
 394  
 395         str = g_string_new(prefix_format);
 396         linebuf_size = max_width+1; linebuf = g_malloc(linebuf_size);
 397  
 398         col = 0; row = 0;
 399         for (tmp = nicklist; tmp != NULL; tmp = tmp->next) {
 400                 NICK_REC *rec = tmp->data;
 401  
 402                 if (rec->prefixes[0])
 403                         nickmode[0] = rec->prefixes[0];
 404                 else 
 405                         nickmode[0] = ' ';
 406                  
 407                 if (linebuf_size < columns[col]-item_extra+1) {   /* Null Pointer Dereference (ID: 7297.28386) */
 408                         linebuf_size = (columns[col]-item_extra+1)*2;
 409                         linebuf = g_realloc(linebuf, linebuf_size);
 410                 }
 411                 memset(linebuf, ' ', columns[col]-item_extra);
 412                 linebuf[columns[col]-item_extra] = '\0';
 413                 memcpy(linebuf, rec->nick, strlen(rec->nick));
 414  
 415                 formatnum = rec->op ? TXT_NAMES_NICK_OP : 
 416                         rec->halfop ? TXT_NAMES_NICK_HALFOP : 
 417                         rec->voice ? TXT_NAMES_NICK_VOICE : 
 418                         TXT_NAMES_NICK;
 419                 format = format_get_text(MODULE_NAME, NULL,
 420                                          channel->server,
 421                                          channel->visible_name,
 422                                          formatnum, nickmode, linebuf);
 423                 g_string_append(str, format);
 424                 g_free(format);
 425  
 426                 if (++col == cols) {
 427                         printtext(channel->server, channel->visible_name,
 428                                   MSGLEVEL_CLIENTCRAP, "%s", str->str);
 429                         g_string_truncate(str, 0);
true430                         if (prefix_format != NULL)
 431                                 g_string_assign(str, prefix_format);
 432                         col = 0; row++;
 433  
 434                         if (row == last_col_rows)
 435                                 cols--;
 436                 }
 437         }
 438  
prefix_format <= 4095439         if (str->len > strlen(prefix_format)) {     /* Null Pointer Dereference */
Preconditions
nicklist >= 1
&$unknown_407800 >= 1
&$unknown_407814 overflowed
channel->server = 0
((char*)((char*)$unknown_407808)[4])[28] = 0
((char*)((char*)$unknown_407808)[4])[28] = 0
((char*)((char*)$unknown_407808)[4])[28] != 0
((char*)((char*)$unknown_407808)[4])[29] = 0
((char*)windows->data)[8] <= 0
((char*)&((char*)$unknown_407808)[4])[4] = 0
strlen(((char*)((char*)$unknown_407808)[4])[12]) = 0
strlen(((char*)$unknown_407808)[4]) = 29
strlen($unknown_407798) != 0
((char*)&$unknown_407798)[8] >= ((char*)&$unknown_407798)[4] + 2
strlen(&$unknown_407804) = 3
((char*)&$unknown_407804)[2] != 0
((char*)&$unknown_407804)[3] = 0
((char*)&$unknown_407804)[1] != 0
((char*)&$unknown_407804)[1] <= 95
((char*)&$unknown_407816)[4] <= ((char*)&$unknown_407816)[8] - 2
mainconfig = 0
Postconditions
strlen(&$unknown_407805)' = 0
col' = 0
columns' = &$unknown_407811
dest.level' = 524288
dest.server' = channel->server
dest.server_tag' = 0
dest.target' = channel->visible_name
format' = $unknown_407816
formatnum' = 81
item_extra' = strlen(&$unknown_407799)
last_col_rows' = 1
linebuf' = &$unknown_407818
linebuf_size' = &$unknown_407814
max_width' = 10
nicklist' = &$unknown_407807
strlen(&nickmode[0])' != 0
nickmode[1]' = 0
prefix_format' = 0
rec' = ((char*)$unknown_407808)[4]
row' = 1
rows' = 1
str' = &$unknown_407810
stripped' = &$unknown_407805
tmp' = ((char*)&((char*)$unknown_407808)[4])[4]
window' = windows->data




Change Warning 7296.28385 : Null Pointer Dereference

Priority:
State:
Finding:
Owner:
Note: