Source-Changes-HG archive

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

[src/trunk]: src/lib/libquota Fix stupid bug in cursor_getn - it's supposed t...



details:   https://anonhg.NetBSD.org/src/rev/b68d49288445
branches:  trunk
changeset: 773388:b68d49288445
user:      dholland <dholland%NetBSD.org@localhost>
date:      Wed Feb 01 06:19:05 2012 +0000

description:
Fix stupid bug in cursor_getn - it's supposed to return the number of
values retrieved, but it was returning 0 on success. Fortunately nothing
was using it yet.

diffstat:

 lib/libquota/quota_kernel.c |  15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)

diffs (42 lines):

diff -r 3e392dee26d2 -r b68d49288445 lib/libquota/quota_kernel.c
--- a/lib/libquota/quota_kernel.c       Wed Feb 01 06:12:37 2012 +0000
+++ b/lib/libquota/quota_kernel.c       Wed Feb 01 06:19:05 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: quota_kernel.c,v 1.3 2012/02/01 05:46:46 dholland Exp $        */
+/*     $NetBSD: quota_kernel.c,v 1.4 2012/02/01 06:19:05 dholland Exp $        */
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: quota_kernel.c,v 1.3 2012/02/01 05:46:46 dholland Exp $");
+__RCSID("$NetBSD: quota_kernel.c,v 1.4 2012/02/01 06:19:05 dholland Exp $");
 
 #include <stdlib.h>
 #include <err.h>
@@ -299,13 +299,22 @@
        struct quotactl_args args;
        unsigned ret;
 
+       if (maxnum > INT_MAX) {
+               /* joker, eh? */
+               errno = EINVAL;
+               return -1;
+       }
+
        args.qc_op = QUOTACTL_CURSORGET;
        args.u.cursorget.qc_cursor = &cursor->kcursor;
        args.u.cursorget.qc_keys = keys;
        args.u.cursorget.qc_vals = vals;
        args.u.cursorget.qc_maxnum = maxnum;
        args.u.cursorget.qc_ret = &ret;
-       return __quotactl(qh->qh_mountpoint, &args);
+       if (__quotactl(qh->qh_mountpoint, &args) < 0) {
+               return -1;
+       }
+       return ret;
 }
 
 int



Home | Main Index | Thread Index | Old Index