Text   |  XML   |  ReML   |   Visible Warnings:

File System Race Condition  at disabled_protos.c:398

No properties have been set. | edit properties
Jump to warning location ↓ warning details...
Show Events | Options

save_disabled_protos_list

(/home/sate/Testcases/c/cve/wireshark-1.2.0/disabled_protos.c)expand/collapse
Show more  
 331  save_disabled_protos_list(char **pref_path_return, int *errno_return)
 332  {
 333    gchar       *ff_path, *ff_path_new;
 334    FILE        *ff;
 335    gint         i;
 336    protocol_t  *protocol;
 337    void        *cookie;
 338   
 339    *pref_path_return = NULL;     /* assume no error */
 340   
 341    ff_path = get_persconffile_path(PROTOCOLS_FILE_NAME, TRUE, TRUE);
 342   
 343    /* Write to "XXX.new", and rename if that succeeds.
 344       That means we don't trash the file if we fail to write it out
 345       completely. */
 346    ff_path_new = g_strdup_printf("%s.new", ff_path);
 347   
 348    if ((ff = ws_fopen(ff_path_new, "w")) == NULL) {
 349      *pref_path_return = ff_path;
 350      *errno_return = errno;
 351      g_free(ff_path_new);
 352      return;
 353    }
 354   
 355    /* Iterate over all the protocols */
 356   
 357[+]   for (i = proto_get_first_protocol(&cookie); i != -1;
 358         i = proto_get_next_protocol(&cookie)) {
 359   
 360      if (!proto_can_toggle_protocol(i)) {
 361        continue;
 362      }
 363   
 364      protocol = find_protocol_by_id(i);
 365      if (proto_is_protocol_enabled(protocol)) {
 366        continue;
 367      }
 368   
 369      /* Write out the protocol name. */
 370      fprintf(ff, "%s\n", proto_get_protocol_filter_name(i));
 371    }
 372   
 373    if (fclose(ff) == EOF) {
 374      *pref_path_return = ff_path;
 375      *errno_return = errno;
 376      ws_unlink(ff_path_new);
 377      g_free(ff_path_new);
 378      return;
 379    }
 380   
 381  #ifdef _WIN32 
 382    /* ANSI C doesn't say whether "rename()" removes the target if it 
 383       exists; the Win32 call to rename files doesn't do so, which I
 384       infer is the reason why the MSVC++ "rename()" doesn't do so.
 385       We must therefore remove the target file first, on Windows. */
 386    if (ws_remove(ff_path) < 0 && errno != ENOENT) {
 387      /* It failed for some reason other than "it's not there"; if 
 388         it's not there, we don't need to remove it, so we just 
 389         drive on. */
 390      *pref_path_return = ff_path;
 391      *errno_return = errno;
 392      ws_unlink(ff_path_new);
 393      g_free(ff_path_new);
 394      return;
 395    }
 396  #endif
 397   
 398    if (ws_rename(ff_path_new, ff_path) < 0) {
Show more  




Change Warning 4248.30616 : File System Race Condition

Priority:
State:
Finding:
Owner:
Note: