Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
bgColor#ccccff
 pthread_mutexattr_t attr;
 pthread_mutex_t mutex;
 size_t const shared_var = 0;

 int main(){
     int rc =0;

     rc = pthread_mutexattr_settype(&mutex, PTHREAD_MUTEX_ERRORCHECK);
     if(rc != 0){
       /* Handle Error */
     }


     rc = pthread_mutex_init(&mutex, &attr);
     if(rc != 0){
       /* Handle Error */
     }


     rc = pthread_mutex_lock(&mutex);
     if(rc != 0){
       /* Handle Error */
     }

     /* Critical Region*/

     rc = pthread_mutex_unlock(&mutex);
     if(rc != 0){
       /* Handle Error */
     }


     return 0;
 }

Risk Assessment

Using NORMAL pthread locks can lead to deadlocks or abnormal program termination.

Recommendation

Severity

Likelihood

Remediation Cost

Priority

Level

POS04-C

low

likely

medium

P6

L2

...