Sat Jun 11 06:40:24 2016 UTC ()
PR 51200 gets in libsa considered harmful: use kgets


(dholland)
diff -r1.27 -r1.28 src/sys/arch/sandpoint/stand/altboot/main.c

cvs diff -r1.27 -r1.28 src/sys/arch/sandpoint/stand/altboot/main.c (expand / switch to unified diff)

--- src/sys/arch/sandpoint/stand/altboot/main.c 2015/09/30 14:14:32 1.27
+++ src/sys/arch/sandpoint/stand/altboot/main.c 2016/06/11 06:40:24 1.28
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: main.c,v 1.27 2015/09/30 14:14:32 phx Exp $ */ 1/* $NetBSD: main.c,v 1.28 2016/06/11 06:40:24 dholland Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2007 The NetBSD Foundation, Inc. 4 * Copyright (c) 2007 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Tohru Nishimura. 8 * by Tohru Nishimura.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -633,27 +633,27 @@ check_bootname(char *s) @@ -633,27 +633,27 @@ check_bootname(char *s)
633 ++s; 633 ++s;
634 } 634 }
635 return *s == ':'; 635 return *s == ':';
636 } 636 }
637 return 0; 637 return 0;
638} 638}
639 639
640static int input_cmdline(char **argv, int maxargc) 640static int input_cmdline(char **argv, int maxargc)
641{ 641{
642 char *cmdline; 642 char *cmdline;
643 643
644 printf("\nbootargs> "); 644 printf("\nbootargs> ");
645 cmdline = alloc(256); 645 cmdline = alloc(256);
646 gets(cmdline); 646 kgets(cmdline, 256);
647 647
648 return parse_cmdline(argv, maxargc, cmdline, 648 return parse_cmdline(argv, maxargc, cmdline,
649 cmdline + strlen(cmdline)); 649 cmdline + strlen(cmdline));
650} 650}
651 651
652static int 652static int
653parse_cmdline(char **argv, int maxargc, char *p, char *end) 653parse_cmdline(char **argv, int maxargc, char *p, char *end)
654{ 654{
655 int argc; 655 int argc;
656 656
657 argv[0] = ""; 657 argv[0] = "";
658 for (argc = 1; argc < maxargc && p < end; argc++) { 658 for (argc = 1; argc < maxargc && p < end; argc++) {
659 while (is_space(*p)) 659 while (is_space(*p))
@@ -676,27 +676,27 @@ is_space(char c) @@ -676,27 +676,27 @@ is_space(char c)
676 return c > '\0' && c <= ' '; 676 return c > '\0' && c <= ' ';
677} 677}
678 678
679#ifdef DEBUG 679#ifdef DEBUG
680static void 680static void
681findflash(void) 681findflash(void)
682{ 682{
683 char buf[256]; 683 char buf[256];
684 int i, n; 684 int i, n;
685 unsigned char c, *p; 685 unsigned char c, *p;
686 686
687 for (;;) { 687 for (;;) {
688 printf("\nfind> "); 688 printf("\nfind> ");
689 gets(buf); 689 kgets(buf, sizeof(buf));
690 if (tolower((unsigned)buf[0]) == 'x') 690 if (tolower((unsigned)buf[0]) == 'x')
691 break; 691 break;
692 for (i = 0, n = 0, c = 0; buf[i]; i++) { 692 for (i = 0, n = 0, c = 0; buf[i]; i++) {
693 c <<= 4; 693 c <<= 4;
694 c |= hex2nibble(buf[i]); 694 c |= hex2nibble(buf[i]);
695 if (i & 1) 695 if (i & 1)
696 buf[n++] = c; 696 buf[n++] = c;
697 } 697 }
698 printf("Searching for:"); 698 printf("Searching for:");
699 for (i = 0; i < n; i++) 699 for (i = 0; i < n; i++)
700 printf(" %02x", buf[i]); 700 printf(" %02x", buf[i]);
701 printf("\n"); 701 printf("\n");
702 for (p = (unsigned char *)0xff000000; 702 for (p = (unsigned char *)0xff000000;
@@ -734,27 +734,27 @@ sat_test(void) @@ -734,27 +734,27 @@ sat_test(void)
734 for (j = 0; j < n; j++) 734 for (j = 0; j < n; j++)
735 printf("%02x ", (unsigned)buf[i + j]); 735 printf("%02x ", (unsigned)buf[i + j]);
736 for (; j < 16; j++) 736 for (; j < 16; j++)
737 printf(" "); 737 printf(" ");
738 putchar('\"'); 738 putchar('\"');
739 for (j = 0; j < n; j++) { 739 for (j = 0; j < n; j++) {
740 c = buf[i + j]; 740 c = buf[i + j];
741 putchar((c >= 0x20 && c <= 0x7e) ? c : '.'); 741 putchar((c >= 0x20 && c <= 0x7e) ? c : '.');
742 } 742 }
743 printf("\"\n"); 743 printf("\"\n");
744 } 744 }
745 745
746 printf("controller> "); 746 printf("controller> ");
747 gets(buf); 747 kgets(buf, sizeof(buf));
748 if (buf[0] == '*' && buf[1] == 'X') 748 if (buf[0] == '*' && buf[1] == 'X')
749 break; 749 break;
750 750
751 if (buf[0] == '0' && tolower((unsigned)buf[1]) == 'x') { 751 if (buf[0] == '0' && tolower((unsigned)buf[1]) == 'x') {
752 for (i = 2, n = 0, c = 0; buf[i]; i++) { 752 for (i = 2, n = 0, c = 0; buf[i]; i++) {
753 c <<= 4; 753 c <<= 4;
754 c |= hex2nibble(buf[i]); 754 c |= hex2nibble(buf[i]);
755 if (i & 1) 755 if (i & 1)
756 buf[n++] = c; 756 buf[n++] = c;
757 } 757 }
758 } else 758 } else
759 n = strlen(buf); 759 n = strlen(buf);
760 760