From 9cf5d4501503fc92a967293aa1ba68179b507bba Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Thu, 26 Oct 2006 01:32:49 +0000 Subject: [PATCH] reduce the possibility of race conditions when using the lock utility SVN-Revision: 5297 --- openwrt/package/busybox/patches/340-lock_util.patch | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/openwrt/package/busybox/patches/340-lock_util.patch b/openwrt/package/busybox/patches/340-lock_util.patch index 9e2075da17..c9c3753937 100644 --- a/openwrt/package/busybox/patches/340-lock_util.patch +++ b/openwrt/package/busybox/patches/340-lock_util.patch @@ -41,7 +41,7 @@ diff -urN busybox.old/miscutils/Makefile.in busybox.dev/miscutils/Makefile.in diff -urN busybox.old/miscutils/lock.c busybox.dev/miscutils/lock.c --- busybox.old/miscutils/lock.c 1970-01-01 01:00:00.000000000 +0100 +++ busybox.dev/miscutils/lock.c 2006-03-14 09:50:40.000000000 +0100 -@@ -0,0 +1,128 @@ +@@ -0,0 +1,130 @@ +#include +#include +#include @@ -96,9 +96,11 @@ diff -urN busybox.old/miscutils/lock.c busybox.dev/miscutils/lock.c + int pid; + char pidstr[8]; + -+ if ((fd = open(file, O_RDWR | O_CREAT, 0700)) < 0) { -+ fprintf(stderr, "Can't open %s\n", file); -+ return 1; ++ if ((fd = open(file, O_RDWR | O_CREAT | O_EXCL, 0700)) < 0) { ++ if ((fd = open(file, O_RDWR)) < 0) { ++ fprintf(stderr, "Can't open %s\n", file); ++ return 1; ++ } + } + + if (flock(fd, (shared ? LOCK_SH : LOCK_EX)) < 0) { -- 2.30.2