Text  |   XML   |   Visible Warnings:

Irssi : Irssi analysis 1 : Buffer Overrun  at textbuffer-commands.c:236

Categories: LANG.MEM.BO CWE:120 CWE:121 CWE:122 CWE:126
Warning ID: 2394.2406
Similar Warnings: 2394.2407, 2394.2408
Procedure: scrollback_goto_time
Trace: View
Modified: Wed Sep 2 12:24:13 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-text/textbuffer-commands.c
   Enter scrollback_goto_time
 186 static void scrollback_goto_time(const char *datearg, const char *timearg) 
 187 {
 188         LINE_REC *line;
 189         struct tm tm;
 190         time_t now, stamp;
 191         int day, month;
 192  
 193         /* [dd[.mm] | -<days ago>] hh:mi[:ss] */ 
 194         now = stamp = time(NULL);
 195         if (*datearg == '-') {
 196                 /* -<days ago> */ 
 197                 stamp -= atoi(datearg+1) * 3600*24;
 198                 memcpy(&tm, localtime(&stamp), sizeof(struct tm));   /* Buffer Overrun (ID: 2394.2407) */
 199         } else if (*timearg != '\0') {
 200                 /* dd[.mm] */ 
 201                 memcpy(&tm, localtime(&stamp), sizeof(struct tm));   /* Buffer Overrun (ID: 2394.2408) */
 202  
 203                 day = month = 0;
 204                 sscanf(datearg, "%d.%d", &day, &month);
 205                 if (day <= 0) return;
 206  
 207                 if (month <= 0) {
 208                         /* month not given */ 
 209                         if (day > tm.tm_mday) {
 210                                 /* last month's day */ 
 211                                 if (tm.tm_mon > 0)
 212                                         tm.tm_mon--;
 213                                 else {
 214                                         /* last year's day.. */ 
 215                                         tm.tm_year--;
 216                                         tm.tm_mon = 11;
 217                                 }
 218                         }
 219                 } else {
 220                         month--;
 221                         if (month > tm.tm_mon)
 222                                 tm.tm_year--;
 223                         tm.tm_mon = month;
 224                 }
 225  
 226                 tm.tm_mday = day;
 227                 stamp = mktime(&tm);
 228         }
 229         else 
 230         {
 231                 /* only time given, move it to timearg */ 
 232                 timearg = datearg;
 233         }
 234  
 235         /* hh:mi[:ss] */ 
true236         memcpy(&tm, localtime(&stamp), sizeof(struct tm));     /* Buffer Overrun */
Preconditions
&$unknown_3432543 >= 1
&$unknown_3432544 >= 1
&$unknown_3432544 >= tm.tm_mon + 2
&$unknown_3432546 = 56
*$param_1 != 45
*$param_2 != 0
strlen($param_2) != 0
Postconditions
datearg' = $param_1
day' = &$unknown_3432543
month' = &$unknown_3432544 - 1
timearg' = $param_2
tm.tm_sec' = &$unknown_3432545
tm.tm_mon' = &$unknown_3432544 - 1
tm.tm_year' = tm.tm_year - 1
tm.tm_mday' = &$unknown_3432543
tmbuf.tm_sec' = &$unknown_3432545




Change Warning 2394.2406 : Buffer Overrun

Because they are very similar, this warning shares annotations with warnings 2394.2407 and 2394.2408.

Priority:
State:
Finding:
Owner:
Note: