Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/flock Don't crash if "flock" is used to lock a file ...



details:   https://anonhg.NetBSD.org/src/rev/80517c2572f1
branches:  trunk
changeset: 784721:80517c2572f1
user:      tron <tron%NetBSD.org@localhost>
date:      Thu Feb 07 13:57:40 2013 +0000

description:
Don't crash if "flock" is used to lock a file descriptor e.g. via
"flock --nb 8".

diffstat:

 usr.bin/flock/flock.c |  9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diffs (32 lines):

diff -r 3262242214e1 -r 80517c2572f1 usr.bin/flock/flock.c
--- a/usr.bin/flock/flock.c     Thu Feb 07 13:33:50 2013 +0000
+++ b/usr.bin/flock/flock.c     Thu Feb 07 13:57:40 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: flock.c,v 1.6 2012/11/02 17:03:16 christos Exp $       */
+/*     $NetBSD: flock.c,v 1.7 2013/02/07 13:57:40 tron Exp $   */
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: flock.c,v 1.6 2012/11/02 17:03:16 christos Exp $");
+__RCSID("$NetBSD: flock.c,v 1.7 2013/02/07 13:57:40 tron Exp $");
 
 #include <stdio.h>
 #include <string.h>
@@ -212,9 +212,12 @@
                if (cls)
                        usage("Close is valid only for descriptors");
                fd = strtol(argv[0], NULL, 0);  // XXX: error checking
-               if (debug)
+               if (debug) {
                        fprintf(stderr, "descriptor %s lock %s\n",
                            argv[0], lock2name(lock));
+               }
+               break;
+
        default:
                if ((lock & LOCK_NB) == LOCK_UN)
                        usage("Unlock is only valid for descriptors");



Home | Main Index | Thread Index | Old Index