Race condition without flows?

Let's say I have: sample.c

int main (...) {

  char str*;

  get s through user input

  test(str);

  return 0;

}

void test (str) {

   copy str to new file 

   change file permissions on new file

   close file

}

There is no possibility of a race condition, since I have no threads in my main () method. It's true?

+3
source share
5 answers

There is some kind of race condition in which the user can exchange a β€œnew file” immediately before changing the rights to the β€œnew file”. This (was?) A commonly used security exploit.

I just see that Neil Butterworth had a related idea.

+8
source

There is the possibility of a race - two users can simultaneously run your program.

+6
source

. , ( )

+1

At any time when you make a system call, there is the possibility of a race condition. This is due to the fact that the kernel connects all the threads in the system and allows you to control the interaction between processes. In this case, another thread in the system may access the same file as your application.

0
source

boost :: filesystem docs have good explanations of the file system race conditions that apply to file systems in general.

0
source

Source: https://habr.com/ru/post/1758764/


All Articles