diff options
author | jb <jb@FreeBSD.org> | 2004-03-09 02:44:59 +0000 |
---|---|---|
committer | jb <jb@FreeBSD.org> | 2004-03-09 02:44:59 +0000 |
commit | e9062915d30751c7edfb1855484e1aaeca783ca6 (patch) | |
tree | 07a7908410c497b79289bf7098dfa4d4a853ee82 /lib/libc/stdio/_flock_stub.c | |
parent | 39dab43424b65b9203b2cfcb9c017cd0cb383038 (diff) | |
download | FreeBSD-src-e9062915d30751c7edfb1855484e1aaeca783ca6.zip FreeBSD-src-e9062915d30751c7edfb1855484e1aaeca783ca6.tar.gz |
On 4.X it was possible for an application to initialise a local FILE
structure and call stdio functions. In 5.X this was broken when FILE
locking was introduced into libc.
This change makes most (relevant) stdio functions work again when the
_extra file in FILE isn't initialised (and can't be without a libc
function to do it since the __sFILEX structure is private to libc).
Diffstat (limited to 'lib/libc/stdio/_flock_stub.c')
-rw-r--r-- | lib/libc/stdio/_flock_stub.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/libc/stdio/_flock_stub.c b/lib/libc/stdio/_flock_stub.c index 8abc8e3..1b79ce2 100644 --- a/lib/libc/stdio/_flock_stub.c +++ b/lib/libc/stdio/_flock_stub.c @@ -73,7 +73,9 @@ _flockfile(FILE *fp) { pthread_t curthread = _pthread_self(); - if (fp->_lock->fl_owner == curthread) + if (fp->_lock == NULL) { + } + else if (fp->_lock->fl_owner == curthread) fp->_lock->fl_count++; else { /* @@ -101,7 +103,9 @@ _ftrylockfile(FILE *fp) pthread_t curthread = _pthread_self(); int ret = 0; - if (fp->_lock->fl_owner == curthread) + if (fp->_lock == NULL) { + } + else if (fp->_lock->fl_owner == curthread) fp->_lock->fl_count++; /* * Make sure this mutex is treated as a private @@ -121,10 +125,12 @@ _funlockfile(FILE *fp) { pthread_t curthread = _pthread_self(); + if (fp->_lock == NULL) { + } /* * Check if this file is owned by the current thread: */ - if (fp->_lock->fl_owner == curthread) { + else if (fp->_lock->fl_owner == curthread) { /* * Check if this thread has locked the FILE * more than once: |