Sun Dec 3 12:53:52 2017 UTC ()
Fix uninitialized pointer, found by Mootja. Not a surprise in untested
code.


(maxv)
diff -r1.57 -r1.58 src/sys/compat/ultrix/ultrix_fs.c

cvs diff -r1.57 -r1.58 src/sys/compat/ultrix/ultrix_fs.c (expand / switch to unified diff)

--- src/sys/compat/ultrix/ultrix_fs.c 2017/04/13 09:18:18 1.57
+++ src/sys/compat/ultrix/ultrix_fs.c 2017/12/03 12:53:52 1.58
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: ultrix_fs.c,v 1.57 2017/04/13 09:18:18 hannken Exp $ */ 1/* $NetBSD: ultrix_fs.c,v 1.58 2017/12/03 12:53:52 maxv Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1995, 1997 Jonathan Stone 4 * Copyright (c) 1995, 1997 Jonathan Stone
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -23,27 +23,27 @@ @@ -23,27 +23,27 @@
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE 25 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE. 32 * SUCH DAMAGE.
33 */ 33 */
34 34
35#include <sys/cdefs.h> 35#include <sys/cdefs.h>
36__KERNEL_RCSID(0, "$NetBSD: ultrix_fs.c,v 1.57 2017/04/13 09:18:18 hannken Exp $"); 36__KERNEL_RCSID(0, "$NetBSD: ultrix_fs.c,v 1.58 2017/12/03 12:53:52 maxv Exp $");
37 37
38#include <sys/param.h> 38#include <sys/param.h>
39#include <sys/systm.h> 39#include <sys/systm.h>
40#include <sys/malloc.h> 40#include <sys/malloc.h>
41#include <sys/exec.h> 41#include <sys/exec.h>
42#include <sys/namei.h> 42#include <sys/namei.h>
43#include <sys/mount.h> 43#include <sys/mount.h>
44#include <sys/proc.h> 44#include <sys/proc.h>
45#include <sys/vnode.h> 45#include <sys/vnode.h>
46#include <sys/vnode_if.h> 46#include <sys/vnode_if.h>
47#include <net/if.h> 47#include <net/if.h>
48#include <netinet/in.h> 48#include <netinet/in.h>
49 49
@@ -266,41 +266,42 @@ ultrix_sys_getmnt(struct lwp *l, const s @@ -266,41 +266,42 @@ ultrix_sys_getmnt(struct lwp *l, const s
266 if (mntflags != MNT_WAIT && 266 if (mntflags != MNT_WAIT &&
267 (error = VFS_STATVFS(mp, sp)) != 0) 267 (error = VFS_STATVFS(mp, sp)) != 0)
268 continue; 268 continue;
269 269
270 /* 270 /*
271 * XXX what does this do? -- cgd 271 * XXX what does this do? -- cgd
272 */ 272 */
273 sp->f_flag = mp->mnt_flag & MNT_VISFLAGMASK; 273 sp->f_flag = mp->mnt_flag & MNT_VISFLAGMASK;
274 if (path == NULL || 274 if (path == NULL ||
275 strcmp(path, sp->f_mntonname) == 0) { 275 strcmp(path, sp->f_mntonname) == 0) {
276 make_ultrix_mntent(sp, &tem); 276 make_ultrix_mntent(sp, &tem);
277 if ((error = copyout((void *)&tem, sfsp, 277 if ((error = copyout((void *)&tem, sfsp,
278 sizeof(tem))) != 0) { 278 sizeof(tem))) != 0) {
279 goto bad; 279 goto bad_freeiter;
280 } 280 }
281 sfsp++; 281 sfsp++;
282 count++; 282 count++;
283 } 283 }
284 } 284 }
285 } 285 }
286 286
287 if (sfsp != NULL && count > maxcount) 287 if (sfsp != NULL && count > maxcount)
288 *retval = maxcount; 288 *retval = maxcount;
289 else 289 else
290 *retval = count; 290 *retval = count;
291 291
292bad: 292bad_freeiter:
293 mountlist_iterator_destroy(iter); 293 mountlist_iterator_destroy(iter);
 294bad:
294 if (path) 295 if (path)
295 free(path, M_TEMP); 296 free(path, M_TEMP);
296 return error; 297 return error;
297} 298}
298 299
299 300
300 301
301/* Old-style inet sockaddr (no len field) as passed to Ultrix mount(2) */ 302/* Old-style inet sockaddr (no len field) as passed to Ultrix mount(2) */
302struct osockaddr_in { 303struct osockaddr_in {
303 short sin_family; 304 short sin_family;
304 u_short sin_port; 305 u_short sin_port;
305 struct in_addr sin_addr; 306 struct in_addr sin_addr;
306 char sin_zero[8]; 307 char sin_zero[8];