Source-Changes-HG archive

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

[src/trunk]: src/sbin/veriexecctl Fix snprintf usage and, while here, don't t...



details:   https://anonhg.NetBSD.org/src/rev/52bb1d2b79f7
branches:  trunk
changeset: 331020:52bb1d2b79f7
user:      dholland <dholland%NetBSD.org@localhost>
date:      Sun Jul 27 04:23:44 2014 +0000

description:
Fix snprintf usage and, while here, don't trundle off the end of an
array. Part of PR 47976 from Henning Petersen.

diffstat:

 sbin/veriexecctl/veriexecctl.c |  10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diffs (25 lines):

diff -r 294c5396041f -r 52bb1d2b79f7 sbin/veriexecctl/veriexecctl.c
--- a/sbin/veriexecctl/veriexecctl.c    Sun Jul 27 04:16:09 2014 +0000
+++ b/sbin/veriexecctl/veriexecctl.c    Sun Jul 27 04:23:44 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: veriexecctl.c,v 1.36 2014/02/09 13:40:59 maxv Exp $    */
+/*     $NetBSD: veriexecctl.c,v 1.37 2014/07/27 04:23:44 dholland Exp $        */
 
 /*-
  * Copyright 2005 Elad Efrat <elad%NetBSD.org@localhost>
@@ -181,11 +181,11 @@
 
        /* Get fingerprint in ASCII. */
        len = prop_data_size(prop_dictionary_get(entry, "fp"));
-       len *= 2;
-       fp = calloc(1, len + 1);
+       fp = calloc(1, len*2 + 1);
        v = dict_getd(entry, "fp");
-       for (i = 0; i < len; i++)
-               snprintf(fp, len + 1, "%s%02x", fp, v[i] & 0xff);
+       for (i = 0; i < len; i++) {
+               snprintf(&fp[i*2], 3, "%02x", v[i] & 0xff);
+       }
 
        /* Get flags. */
        memset(flags, 0, sizeof(flags));



Home | Main Index | Thread Index | Old Index