pkgsrc-Changes archive

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

CVS commit: pkgsrc/devel/diffbreaker/files/diffbreaker



Module Name:    pkgsrc
Committed By:   nat
Date:           Wed Jun 17 23:52:05 UTC 2020

Modified Files:
        pkgsrc/devel/diffbreaker/files/diffbreaker: diffbreaker.c

Log Message:
Another attempt to fix errors with SSP_FORTIFY set.  Limit the size of
copied strings with strncpy(3).


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 \
    pkgsrc/devel/diffbreaker/files/diffbreaker/diffbreaker.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: pkgsrc/devel/diffbreaker/files/diffbreaker/diffbreaker.c
diff -u pkgsrc/devel/diffbreaker/files/diffbreaker/diffbreaker.c:1.4 pkgsrc/devel/diffbreaker/files/diffbreaker/diffbreaker.c:1.5
--- pkgsrc/devel/diffbreaker/files/diffbreaker/diffbreaker.c:1.4        Wed Jun 17 20:40:28 2020
+++ pkgsrc/devel/diffbreaker/files/diffbreaker/diffbreaker.c    Wed Jun 17 23:52:05 2020
@@ -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 @@ mark_dirty(void)
        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 @@ mark_dirty(void)
                        }
                        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 @@ mark_dirty(void)
                        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 @@ mark_dirty(void)
                        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 @@ mark_dirty(void)
                        /* 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