Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[pkgsrc/trunk]: pkgsrc/devel/diffbreaker/files/diffbreaker Another attempt to...
details: https://anonhg.NetBSD.org/pkgsrc/rev/9cb425220bfc
branches: trunk
changeset: 434516:9cb425220bfc
user: nat <nat%pkgsrc.org@localhost>
date: Wed Jun 17 23:52:05 2020 +0000
description:
Another attempt to fix errors with SSP_FORTIFY set. Limit the size of
copied strings with strncpy(3).
diffstat:
devel/diffbreaker/files/diffbreaker/diffbreaker.c | 13 +++++++------
1 files changed, 7 insertions(+), 6 deletions(-)
diffs (59 lines):
diff -r 5de712049a0c -r 9cb425220bfc devel/diffbreaker/files/diffbreaker/diffbreaker.c
--- a/devel/diffbreaker/files/diffbreaker/diffbreaker.c Wed Jun 17 22:56:16 2020 +0000
+++ b/devel/diffbreaker/files/diffbreaker/diffbreaker.c Wed Jun 17 23:52:05 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: diffbreaker.c,v 1.4 2020/06/17 20:40:28 nat Exp $ */
+/* $NetBSD: diffbreaker.c,v 1.5 2020/06/17 23:52:05 nat Exp $ */
/*-
* Copyright (c) 2018, 2019 Nathanial Sloss <nathanialsloss%yahoo.com.au@localhost>
@@ -91,6 +91,7 @@
bool writetome = false, display = false;
bool pending = false, writesect = false;
ssize_t i, j = 0, last = 0, myfile = 0;
+ size_t len = (size_t)cpl;
j = 0;
for (i = 0; i < totalLines; i++) {
@@ -101,7 +102,7 @@
}
if (*ORIGBUF(i) == '+') {
if (j != i)
- strcpy(ORIGBUF(j), ORIGBUF(i));
+ strncpy(ORIGBUF(j), ORIGBUF(i), len);
*ORIGBUF(j) = ' ';
action[j] = 0;
}
@@ -114,7 +115,7 @@
writesect = false;
action[j] = action[i];
if (j != i)
- strcpy(ORIGBUF(j), ORIGBUF(i));
+ strncpy(ORIGBUF(j), ORIGBUF(i), len);
break;
case 6: /* --- */
if (pending == false && writesect == false)
@@ -126,12 +127,12 @@
writetome = false;
writesect = true;
if (j != i)
- strcpy(ORIGBUF(j), ORIGBUF(i));
+ strncpy(ORIGBUF(j), ORIGBUF(i), len);
action[j] = action[i];
break;
case 7: /* +++ */
if (j != i)
- strcpy(ORIGBUF(j), ORIGBUF(i));
+ strncpy(ORIGBUF(j), ORIGBUF(i), len);
action[j] = action[i];
break;
case 1: /* unselected change */
@@ -141,7 +142,7 @@
/* fallthrough */
default:
if (j != i)
- strcpy(ORIGBUF(j), ORIGBUF(i));
+ strncpy(ORIGBUF(j), ORIGBUF(i), len);
action[j] = action[i];
break;
}
Home |
Main Index |
Thread Index |
Old Index