Ignore:
Timestamp:
Jan 27, 2011, 7:31:06 PM (13 years ago)
Author:
Bruno Cornec
Message:

r4176@localhost: bruno | 2011-01-26 18:11:02 +0100

  • Fix buffer overflow with long exclude lines where log between mindi and mondo were exceeding fixed string size used
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.9/mondo/src/common/newt-specific.c

    r2697 r2700  
    471471
    472472        /*@ buffers ********************************************************** */
    473         char *command;
    474         char *tmp;
     473        char *command = NULL;
     474        char *tmp = NULL;
    475475
    476476        /*@ pointers ********************************************************* */
     
    480480        int i = 0;
    481481
    482         malloc_string(command);
    483         malloc_string(tmp);
    484482        assert_string_is_neither_NULL_nor_zerolength(filename);
    485483        assert(grep_for_me != NULL);
    486484
    487485        if (!does_file_exist(filename)) {
    488             paranoid_free(command);
    489             paranoid_free(tmp);
    490486            return;
    491487        }
    492488        if (grep_for_me[0] != '\0') {
    493             sprintf(command, "grep '%s' %s | tail -n%d",
     489            mr_asprintf(&command, "grep '%s' %s | tail -n%d",
    494490                    grep_for_me, filename, g_noof_log_lines);
    495491        } else {
    496             sprintf(command, "tail -n%d %s", g_noof_log_lines,
     492            mr_asprintf(&command, "tail -n%d %s", g_noof_log_lines,
    497493                    filename);
    498494        }
     
    510506                    */
    511507                    if (!strncmp(err_log_lines[i], "root:", 5)) {
    512                         strcpy(tmp, err_log_lines[i] + 6);
    513                         strcpy(err_log_lines[i], tmp);
     508                        mr_asprintf(&tmp, "%s", err_log_lines[i] + 6);
     509                        strncpy(err_log_lines[i], tmp, (size_t)MAX_NEWT_COMMENT_LEN);
     510                        mr_free(tmp);
    514511                    }
    515512                    if (feof(fin)) {
     
    520517            paranoid_pclose(fin);
    521518        }
     519        mr_free(command);
    522520        refresh_log_screen();
    523         paranoid_free(command);
    524         paranoid_free(tmp);
    525521    }
    526522
     
    545541
    546542        va_start(args, fmt);
    547         vsprintf(output, fmt, args);
     543        vsnprintf(output, MAX_STR_LEN-1, fmt, args);
    548544        log_msg(0, output);
    549545        output[80] = '\0';
Note: See TracChangeset for help on using the changeset viewer.