Text  |   XML   |   Visible Warnings:

Irssi : Irssi analysis 1 : File System Race Condition  at misc.c:410

Categories: POSIX.RACE.TOCTTOU CWE:367
Warning ID: 2094.2095
Procedure: mkpath
Trace: View
Modified: Wed Sep 2 11:51:10 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/core/misc.c
   Enter mkpath
 387 int mkpath(const char *path, int mode) 
 388 {
 389         struct stat statbuf;
 390         const char *p;
 391         char *dir;
 392  
 393         g_return_val_if_fail(path != NULL, -1);
 394  
 395         p = g_path_skip_root((char *) path);
 396         if (p == NULL) {
 397                 /* not a full path, maybe not what we wanted 
 398                    but continue anyway.. */ 
 399                 p = path;
 400         }
 401         for (;;) {
 402                 if (*p != G_DIR_SEPARATOR && *p != '\0') {
 403                         p++;
 404                         continue;
 405                 }
 406  
 407                 dir = g_strndup(path, (int) (p-path));
true408                 if (stat(dir, &statbuf) != 0) {
 409 #ifndef WIN32 
*dir is checked by path name410                         if (mkdir(dir, mode) == -1)     /* File System Race Condition */
 411 #else 
 412                         if (_mkdir(dir) == -1) 
 413 #endif 
 414                         {
 415                                 g_free(dir);
 416                                 return -1;
 417                         }
 418                 }
 419                 g_free(dir);
 420  
 421                 if (*p++ == '\0')
Preconditions
&$unknown_89954 >= $param_1
&$unknown_89957 >= 1
strlen($param_1) != 0
$unknown_89954 != 0
strlen(&$unknown_89954) = 1
((char*)&$unknown_89954)[1] = 0
Postconditions
_g_boolean_var_' = 1
$unknown_89957' is checked by path name
dir' = &$unknown_89957
errno' != 0
mode' = $param_2
p' = &$unknown_89954 + 1
path' = $param_1




Change Warning 2094.2095 : File System Race Condition

Priority:
State:
Finding:
Owner:
Note: