Source-Changes-HG archive

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

[src/netbsd-7]: src/usr.sbin/sysinst Pull up following revision(s) (requested...



details:   https://anonhg.NetBSD.org/src/rev/a4e50781e17e
branches:  netbsd-7
changeset: 798288:a4e50781e17e
user:      riz <riz%NetBSD.org@localhost>
date:      Sat Aug 23 03:44:02 2014 +0000

description:
Pull up following revision(s) (requested by martin in ticket #39):
        usr.sbin/sysinst/main.c: revision 1.4
        usr.sbin/sysinst/disks.c: revision 1.5
        usr.sbin/sysinst/main.c: revision 1.5
        usr.sbin/sysinst/mbr.c: revision 1.3
        usr.sbin/sysinst/net.c: revision 1.3
        usr.sbin/sysinst/net.c: revision 1.4
        usr.sbin/sysinst/partman.c: revision 1.5
        usr.sbin/sysinst/partman.c: revision 1.6
        usr.sbin/sysinst/util.c: revision 1.4
Remove duplicate fclose(), pointed out by coverity scan.
Remove (accidently) duplicated code - pointed out by coverity scan.
Make sure the interface name is 0 terminated, pointed out by coverity scan.
Check return value from getenv() before using the value. Pointed out by
coverity scan.
Make an invariant more clear to avoid fals positives from coverity scan
if chdir() fails, try chdir /
Check return values from stat before comparing contents of the result
structures. Pointed out by coverity scan.
Cosmetic changes trying to appease coverity scan.
Make sure to not dereference a NULL pointer.

diffstat:

 usr.sbin/sysinst/disks.c   |   4 ++--
 usr.sbin/sysinst/main.c    |   7 +++++--
 usr.sbin/sysinst/mbr.c     |   5 ++---
 usr.sbin/sysinst/net.c     |   6 ++----
 usr.sbin/sysinst/partman.c |  13 +++++++------
 usr.sbin/sysinst/util.c    |   9 ++++-----
 6 files changed, 22 insertions(+), 22 deletions(-)

diffs (157 lines):

diff -r c19f68ace61a -r a4e50781e17e usr.sbin/sysinst/disks.c
--- a/usr.sbin/sysinst/disks.c  Fri Aug 22 19:21:53 2014 +0000
+++ b/usr.sbin/sysinst/disks.c  Sat Aug 23 03:44:02 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: disks.c,v 1.4 2014/08/08 20:24:27 riz Exp $ */
+/*     $NetBSD: disks.c,v 1.4.4.1 2014/08/23 03:44:02 riz Exp $ */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -1383,7 +1383,7 @@
                }
        }
 
-       if (dkwl.dkwl_nwedges > 0)
+       if (dkwl.dkwl_nwedges > 0 && *dkw != NULL)
                qsort(*dkw, dkwl.dkwl_nwedges, sizeof(**dkw), get_dkwedges_sort);
 
        close(fd);
diff -r c19f68ace61a -r a4e50781e17e usr.sbin/sysinst/main.c
--- a/usr.sbin/sysinst/main.c   Fri Aug 22 19:21:53 2014 +0000
+++ b/usr.sbin/sysinst/main.c   Sat Aug 23 03:44:02 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.3 2014/08/06 09:11:46 martin Exp $  */
+/*     $NetBSD: main.c,v 1.3.4.1 2014/08/23 03:44:02 riz Exp $ */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -390,7 +390,10 @@
         * XXX must be idempotent, since we get run each time the main
         *     menu is displayed.
         */
-       chdir(getenv("HOME"));
+       char *home = getenv("HOME");
+       if (home != NULL)
+               if (chdir(home) != 0)
+                       (void)chdir("/");
        unwind_mounts();
 
        /* Display banner message in (english, francais, deutsch..) */
diff -r c19f68ace61a -r a4e50781e17e usr.sbin/sysinst/mbr.c
--- a/usr.sbin/sysinst/mbr.c    Fri Aug 22 19:21:53 2014 +0000
+++ b/usr.sbin/sysinst/mbr.c    Sat Aug 23 03:44:02 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mbr.c,v 1.2 2014/08/03 16:09:38 martin Exp $ */
+/*     $NetBSD: mbr.c,v 1.2.4.1 2014/08/23 03:44:02 riz Exp $ */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -1148,8 +1148,7 @@
 #ifdef BOOTSEL
        if (mbri->mbrb.mbrbs_nametab[opt][0] != 0) {
                int x, y;
-               if (opt >= MBR_PART_COUNT)
-                       opt = 0;
+
                getyx(m->mw, y, x);
                if (x > 52) {
                        x = 52;
diff -r c19f68ace61a -r a4e50781e17e usr.sbin/sysinst/net.c
--- a/usr.sbin/sysinst/net.c    Fri Aug 22 19:21:53 2014 +0000
+++ b/usr.sbin/sysinst/net.c    Sat Aug 23 03:44:02 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: net.c,v 1.2 2014/08/03 16:09:38 martin Exp $   */
+/*     $NetBSD: net.c,v 1.2.4.1 2014/08/23 03:44:02 riz Exp $  */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -264,7 +264,7 @@
                if (*ignore != NULL)
                        continue;
 
-               strncpy (devs[i].if_dev, buf, STRSIZE);
+               strlcpy (devs[i].if_dev, buf, STRSIZE);
                i++;
        }
        strcpy(devs[i].if_dev, "\0");
@@ -1176,8 +1176,6 @@
                        write_etc_hosts(hosts);
                        (void)fclose(hosts);
                        scripting_fprintf(NULL, "EOF\n");
-
-                       fclose(hosts);
                }
 
                if (del_rc_conf("defaultroute") == 0)
diff -r c19f68ace61a -r a4e50781e17e usr.sbin/sysinst/partman.c
--- a/usr.sbin/sysinst/partman.c        Fri Aug 22 19:21:53 2014 +0000
+++ b/usr.sbin/sysinst/partman.c        Sat Aug 23 03:44:02 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: partman.c,v 1.4 2014/08/08 20:59:35 riz Exp $ */
+/*     $NetBSD: partman.c,v 1.4.4.1 2014/08/23 03:44:02 riz Exp $ */
 
 /*
  * Copyright 2012 Eugene Lozovoy
@@ -1736,7 +1736,7 @@
                if (wedges[i].pm == pm_cur && ! wedges[i].allocated)
                        wedges[i].pm = NULL;
 
-       for (i = 0; i < MAXPARTITIONS && i < MAX_WEDGES; i++)
+       for (i = 0; i < min(MAXPARTITIONS,MAX_WEDGES); i++)
                if (pm_cur->bsdlabel[i].pi_fstype != FS_UNUSED) {
                        current = pm_wedge_getfree();
                        if (current < 0) {
@@ -2414,17 +2414,18 @@
 
        switch (((part_entry_t *)arg)[m->cursel].type) {
                case PM_DISK_T:
-                       if (pm_cur->gpt) {
+                       if (pm_cur != NULL && pm_cur->gpt) {
                                process_menu(MENU_pmgptentry, &part_num);
                                pm_wedges_fill(pm_cur);
-                       } else
+                       } else {
                                process_menu(MENU_pmdiskentry, &part_num);
+                       }
                        break;
                case PM_WEDGE_T:
                case PM_PART_T:
                        part_num = ((part_entry_t *)arg)[m->cursel].dev_num;
                        process_menu(MENU_pmpartentry, &part_num);
-                       if (pm_cur->gpt)
+                       if (pm_cur != NULL && pm_cur->gpt)
                                pm_wedges_fill(pm_cur);
                        break;
                case PM_SPEC_T:
@@ -2597,7 +2598,7 @@
                if (pm_i->found > 0)
                        pm_i->found = 0;
        /* Detect all present devices */
-       find_disks("partman");
+       (void)find_disks("partman");
        pm_lvm_find();
        pm_clean();
 
diff -r c19f68ace61a -r a4e50781e17e usr.sbin/sysinst/util.c
--- a/usr.sbin/sysinst/util.c   Fri Aug 22 19:21:53 2014 +0000
+++ b/usr.sbin/sysinst/util.c   Sat Aug 23 03:44:02 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: util.c,v 1.3 2014/08/10 16:44:37 tls Exp $     */
+/*     $NetBSD: util.c,v 1.3.2.1 2014/08/23 03:44:02 riz Exp $ */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -1105,10 +1105,9 @@
        if (!update) {
                struct stat sb1, sb2;
 
-               stat(target_expand("/"), &sb1);
-               stat(target_expand("/var"), &sb2);
-
-               if (sb1.st_dev != sb2.st_dev) {
+               if (stat(target_expand("/"), &sb1) == 0
+                   && stat(target_expand("/var"), &sb2) == 0
+                   && sb1.st_dev != sb2.st_dev) {
                        add_rc_conf("random_file=/etc/entropy-file\n");
                        if (target_file_exists_p("/boot.cfg")) {
                                run_program(RUN_CHROOT|RUN_FATAL,



Home | Main Index | Thread Index | Old Index