aboutsummaryrefslogtreecommitdiffstats
path: root/package
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2006-10-26 01:32:49 +0000
committerFelix Fietkau <nbd@openwrt.org>2006-10-26 01:32:49 +0000
commita277034a7d00fb11504e26c8cbfcb019be72e6a3 (patch)
tree4972c287d8e3db67a0c562a36dd64405aa172c26 /package
parent60037e70b76041e9405f69280b2c20951f61e481 (diff)
downloadupstream-a277034a7d00fb11504e26c8cbfcb019be72e6a3.tar.gz
upstream-a277034a7d00fb11504e26c8cbfcb019be72e6a3.tar.bz2
upstream-a277034a7d00fb11504e26c8cbfcb019be72e6a3.zip
reduce the possibility of race conditions when using the lock utility
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@5297 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'package')
-rw-r--r--package/busybox/patches/340-lock_util.patch10
1 files changed, 6 insertions, 4 deletions
diff --git a/package/busybox/patches/340-lock_util.patch b/package/busybox/patches/340-lock_util.patch
index a86948d597..acb4457f38 100644
--- a/package/busybox/patches/340-lock_util.patch
+++ b/package/busybox/patches/340-lock_util.patch
@@ -33,7 +33,7 @@ diff -ruN busybox-1.2.0-old/miscutils/Config.in busybox-1.2.0-new/miscutils/Conf
diff -ruN busybox-1.2.0-old/miscutils/lock.c busybox-1.2.0-new/miscutils/lock.c
--- busybox-1.2.0-old/miscutils/lock.c 1970-01-01 01:00:00.000000000 +0100
+++ busybox-1.2.0-new/miscutils/lock.c 2006-08-01 10:21:15.000000000 +0200
-@@ -0,0 +1,133 @@
+@@ -0,0 +1,135 @@
+/*
+ * Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org>
+ *
@@ -93,9 +93,11 @@ diff -ruN busybox-1.2.0-old/miscutils/lock.c busybox-1.2.0-new/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) {