Text  |   XML   |   Visible Warnings:

irssi-0.8.14 : irssi-0.8.14 analysis 2 : File System Race Condition  at dcc-get.c:227

Categories: IO.RACE CWE:367
Warning ID: 7264.28349
Procedure: sig_dccget_connected
Trace: view
Modified: Thu Nov 26 11:08:59 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/irc/dcc/dcc-get.c
   Enter sig_dccget_connected
 174 void sig_dccget_connected(GET_DCC_REC *dcc) 
 175 {
 176         struct stat statbuf;
 177         char *fname, *tempfname, *str;
 178         int ret, ret_errno, temphandle, old_umask;
 179  
 180         if (!dcc->from_dccserver) {
 181                 if (net_geterror(dcc->handle) != 0) {
 182                         /* error connecting */ 
 183                         signal_emit("dcc error connect", 1, dcc);
 184                         dcc_destroy(DCC(dcc));
 185                         return;
 186                 }
 187  
 188                 g_source_remove(dcc->tagconn);
 189                 dcc->tagconn = -1;
 190         }
 191  
 192         g_free_not_null(dcc->file);
 193         dcc->file = dcc_get_download_path(dcc->arg);
 194  
 195         /* if some plugin wants to change the file name/path here.. */ 
 196         signal_emit("dcc get receive", 1, dcc);
 197  
 198         if (stat(dcc->file, &statbuf) == 0 &&
 199             dcc->get_type == DCC_GET_RENAME) {
 200                 /* file exists, rename.. */ 
 201                 fname = dcc_get_rename_file(dcc->file);
 202                 g_free(dcc->file);
 203                 dcc->file = fname;
 204         }
 205  
 206         if (dcc->get_type != DCC_GET_RESUME) {
 207                 int dcc_file_create_mode = octal2dec(settings_get_int("dcc_file_create_mode"));
 208  
 209                 /* we want to overwrite the file, remove it here.
 210                    if it gets created after this, we'll fail. */ 
true211                 unlink(dcc->file);
 212  
 213                 /* just to make sure we won't run into race conditions 
 214                    if download_path is in some global temp directory */ 
 215                 tempfname = g_strconcat(dcc->file, ".XXXXXX", NULL);
 216  
 217                 old_umask = umask(0077);
 218                 temphandle = mkstemp(tempfname);
 219                 umask(old_umask);
 220  
 221                 if (temphandle == -1)
 222                         ret = -1;
 223                 else 
 224                         ret = fchmod(temphandle, dcc_file_create_mode);
 225  
 226                 if (ret != -1) {
*dcc->file is accessed by path name227                         ret = link(tempfname, dcc->file);     /* File System Race Condition */
Preconditions
dcc->from_dccserver = 0
Postconditions
$unknown_321879' is accessed by path name
$unknown_321882' is accessed by path name
errno' != 0
fname' = &$unknown_321879
old_umask' = 63
ret' = 0
tempfname' = &$unknown_321882
temphandle' != -1




Change Warning 7264.28349 : File System Race Condition

Priority:
State:
Finding:
Owner:
Note: