Text  |   XML   |   Visible Warnings:

Irssi : Irssi analysis 1 : Null Pointer Dereference  at fe-channels.c:439

Categories: LANG.MEM.NPD CWE:476
Warning ID: 2232.2238
Procedure: display_sorted_nicks
Trace: View
Modified: Wed Sep 2 11:53:38 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
   /u1/paul/SATE/2010/c/irssi/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: 2233.2239) */
 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
$param_2 >= 1
&$unknown_651151 >= 1
&$unknown_651162 = 1
&$unknown_651173 = 0
((char*)$param_1)[24] = 0
((char*)windows->data)[16] >= 1
((char*)$unknown_651161)[44] = 0
((char*)$unknown_651161)[44] = 0
((char*)$unknown_651161)[44] != 0
((char*)$unknown_651161)[45] != 0
strlen(((char*)$unknown_651161)[16]) = 0
strlen($unknown_651161) != 45
strlen(&$unknown_651150) = 0
strlen(&$unknown_651157) != 0
((char*)&$unknown_651161)[8] = 0
$unknown_651165 = 0
((char*)&$unknown_651167)[16] >= ((char*)&$unknown_651167)[8] + 2
mainconfig = 0
sending_print_starting != 0
Postconditions
strlen(&$unknown_651149)' = 0
strlen(&$unknown_651166)' = $unknown_651165
channel' = $param_1
col' = 0
cols' = 0
columns' = &$unknown_651165
dest.server_tag' = 0
dest.target' = ((char*)$param_1)[32]
dest.level' = 524288
dest.server' = ((char*)$param_1)[24]
format' = $unknown_651167
formatnum' = 81
item_extra' = 0
last_col_rows' = &$unknown_651162
linebuf' = &$unknown_651166
linebuf_size' = 11
max_width' = 10
nicklist' = &$unknown_651161
nickmode[1]' = 0
prefix_format' = 0
rec' = $unknown_651161
row' = 1
rows' = 1
str' = &$unknown_651170
stripped' = &$unknown_651158
tmp' = ((char*)&$unknown_651161)[8]
window' = windows->data




Change Warning 2232.2238 : Null Pointer Dereference

Priority:
State:
Finding:
Owner:
Note: