Source-Changes-HG archive

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

[src/trunk]: src/sys/nfs Initialize recm to NULL inside the loop, so that a r...



details:   https://anonhg.NetBSD.org/src/rev/ffe787af5979
branches:  trunk
changeset: 534690:ffe787af5979
user:      fvdl <fvdl%NetBSD.org@localhost>
date:      Fri Aug 02 00:09:33 2002 +0000

description:
Initialize recm to NULL inside the loop, so that a record length of
NULL will not accidentallly append bogus data (the previous record).

Derived from a fix by Matt Dillon in FreeBSD.

diffstat:

 sys/nfs/nfs_socket.c |  12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

diffs (47 lines):

diff -r 62729ed57b6d -r ffe787af5979 sys/nfs/nfs_socket.c
--- a/sys/nfs/nfs_socket.c      Thu Aug 01 23:51:42 2002 +0000
+++ b/sys/nfs/nfs_socket.c      Fri Aug 02 00:09:33 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nfs_socket.c,v 1.74 2002/05/12 23:04:36 matt Exp $     */
+/*     $NetBSD: nfs_socket.c,v 1.75 2002/08/02 00:09:33 fvdl Exp $     */
 
 /*
  * Copyright (c) 1989, 1991, 1993, 1995
@@ -43,7 +43,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nfs_socket.c,v 1.74 2002/05/12 23:04:36 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_socket.c,v 1.75 2002/08/02 00:09:33 fvdl Exp $");
 
 #include "fs_nfs.h"
 #include "opt_nfs.h"
@@ -2048,7 +2048,7 @@
        struct mbuf *m, **mpp;
        char *cp1, *cp2;
        int len;
-       struct mbuf *om, *m2, *recm = NULL;
+       struct mbuf *om, *m2, *recm;
        u_int32_t recmark;
 
        if (slp->ns_flag & SLP_GETSTREAM)
@@ -2093,6 +2093,9 @@
 
            /*
             * Now get the record part.
+            *
+            * Note that slp->ns_reclen may be 0.  Linux sometimes
+            * generates 0-length records.
             */
            if (slp->ns_cc == slp->ns_reclen) {
                recm = slp->ns_raw;
@@ -2101,7 +2104,8 @@
            } else if (slp->ns_cc > slp->ns_reclen) {
                len = 0;
                m = slp->ns_raw;
-               om = (struct mbuf *)0;
+               recm = om = NULL;
+
                while (len < slp->ns_reclen) {
                        if ((len + m->m_len) > slp->ns_reclen) {
                                size_t left = slp->ns_reclen - len;



Home | Main Index | Thread Index | Old Index