summary: Test for bz503723 (fopen mode 'x' ignored in some cases)
description: |
    Bug summary: fopen mode 'x' ignored in some cases
    Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=503723

    Description:

    Created an attachment (id=346240)
    fopen.c - test for fopen modes

    Description of problem:
    O_EXCL is not used if mode is "wbex", but O_EXCL is used if mode is "wbxe".

    This bug can cause security vulnerabilities in software relying on this glibc extension.

    Version-Release number of selected component (if applicable):
    2.10.1-2, 2.9.90-3

    How reproducible:
    always

    Steps to Reproduce:
    1. compile attached C source file
    2. run with options ababab wbex, and ababab wbxe
    3.
      
    Actual results:
    'x' may be ignored

    Expected results:
    'x' not ignored

    Additional info:
    $ strace -eopen ./a.out ababab wbxe 2>&1 | grep ababab ; rm -f ababab
    open("ababab", O_WRONLY|O_CREAT|O_EXCL|O_TRUNC|O_CLOEXEC, 0666) = 3
    $ strace -eopen ./a.out ababab wbex 2>&1 | grep ababab ; rm -f ababab
    open("ababab", O_WRONLY|O_CREAT|O_TRUNC|O_CLOEXEC, 0666) = 3
contact: Petr Muller <pmuller@redhat.com>
component:
  - glibc
test: ./runtest.sh
framework: beakerlib
recommend:
  - glibc
  - perl
  - strace
  - python
  - python3
  - python38
tag:
  - simple
  - tier1_mfranc
  - mfranc_stable
  - noEWA
  - Tier1
  - not-er15271
  - glibc-buildroot-ready
  - NoRHEL4
duration: 90m
link:
  - relates: https://bugzilla.redhat.com/show_bug.cgi?id=503723
extra-summary: /tools/glibc/Regression/bz503723-fopen-mode-x-ignored-in-some-cases
extra-task: /tools/glibc/Regression/bz503723-fopen-mode-x-ignored-in-some-cases
