Source-Changes-HG archive

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

[src/trunk]: src/tests/lib/libcurses/director Fix off-by-one error and simpli...



details:   https://anonhg.NetBSD.org/src/rev/6b50eb0f3ed1
branches:  trunk
changeset: 770186:6b50eb0f3ed1
user:      joerg <joerg%NetBSD.org@localhost>
date:      Fri Oct 07 13:39:33 2011 +0000

description:
Fix off-by-one error and simplify at the same time.

diffstat:

 tests/lib/libcurses/director/director.c      |  6 ++----
 tests/lib/libcurses/director/testlang_conf.l |  6 ++----
 2 files changed, 4 insertions(+), 8 deletions(-)

diffs (45 lines):

diff -r 1d41be4f7bca -r 6b50eb0f3ed1 tests/lib/libcurses/director/director.c
--- a/tests/lib/libcurses/director/director.c   Fri Oct 07 10:52:31 2011 +0000
+++ b/tests/lib/libcurses/director/director.c   Fri Oct 07 13:39:33 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: director.c,v 1.8 2011/09/15 11:53:12 blymn Exp $       */
+/*     $NetBSD: director.c,v 1.9 2011/10/07 13:39:33 joerg Exp $       */
 
 /*-
  * Copyright 2009 Brett Lymn <blymn%NetBSD.org@localhost>
@@ -267,11 +267,9 @@
        if ((yyin = fopen(argv[0], "r")) == NULL)
                err(1, "Cannot open command file %s", argv[0]);
 
-       if ((cur_file = malloc(strlen(argv[0]) + 1)) == NULL)
+       if ((cur_file = strdup(argv[0])) == NULL)
                err(2, "Failed to alloc memory for test file name");
 
-       strlcpy(cur_file, argv[0], strlen(argv[0]) + 1);
-
        init_parse_variables(1);
 
        yyparse();
diff -r 1d41be4f7bca -r 6b50eb0f3ed1 tests/lib/libcurses/director/testlang_conf.l
--- a/tests/lib/libcurses/director/testlang_conf.l      Fri Oct 07 10:52:31 2011 +0000
+++ b/tests/lib/libcurses/director/testlang_conf.l      Fri Oct 07 13:39:33 2011 +0000
@@ -1,5 +1,5 @@
 %{
-/*     $NetBSD: testlang_conf.l,v 1.5 2011/06/18 20:05:28 joerg Exp $  */
+/*     $NetBSD: testlang_conf.l,v 1.6 2011/10/07 13:39:33 joerg Exp $  */
 
 /*-
  * Copyright 2009 Brett Lymn <blymn%NetBSD.org@localhost>
@@ -197,11 +197,9 @@
 
                include_stack[include_ptr] = line;
                include_files[include_ptr++] = cur_file;
-               cur_file = malloc(strlen(inc_file));
+               cur_file = strdup(inc_file);
                if (cur_file == NULL)
                        err(2, "Cannot allocate new include file string");
-
-               strlcpy(cur_file, inc_file, sizeof(inc_file));
                line = 0;
                BEGIN(INITIAL);
        }



Home | Main Index | Thread Index | Old Index