void-packages/srcpkgs/64tass/patches/fix-lines-limit.patch
Đoàn Trần Công Danh 75403cef76 srcpkgs/[0-9]*: convert patches to -Np1
```sh
git grep -l '^patch_args=-Np0' "srcpkgs/$1*/template" |
while read template; do
	for p in ${template%/template}/patches/*; do
		sed -i '
			\,^[+-][+-][+-] /dev/null,b
			/^[*-]\+ [0-9]\+\(,[0-9]\+\)\? [*-]\+$/b
			s,^[*][*][*] ,&a/,
			/^--- /{
				s,\(^--- \)\(./\)*,\1a/,
				s,[.-][Oo][Rr][Ii][Gg]\([	/]\),\1,
				s/[.-][Oo][Rr][Ii][Gg]$//
				s/[.]patched[.]\([^.]\)/.\1/
				h
			}
			/^+++ -/{
				g
				s/^--- a/+++ b/
				b
			}
			s,\(^+++ \)\(./\)*,\1b/,
		' "$p"
	done
	sed -i '/^patch_args=/d' $template
done
```
2021-06-20 13:17:29 +07:00

25 lines
1.3 KiB
Diff

--- a/file.c 2020-04-07 21:18:24.000000000 +0200
+++ b/file.c 2020-04-22 20:11:45.714713362 +0200
@@ -493,7 +493,8 @@
tmp->data = (uint8_t *)malloc(len2);
if (tmp->data != NULL) tmp->len = len2;
max_lines = (len2 / 20 + 1024) & ~(size_t)1023;
- if (max_lines > SIZE_MAX / sizeof *tmp->line) max_lines = SIZE_MAX / sizeof *tmp->line; /* overflow */
+ if (max_lines >= INT32_MAX / sizeof *tmp->line)
+ max_lines = (INT32_MAX - 1) / sizeof *tmp->line; /* overflow */
tmp->line = (size_t *)malloc(max_lines * sizeof *tmp->line);
if (tmp->line == NULL) max_lines = 0;
}
@@ -718,8 +719,11 @@
last_ubuff = ubuff;
tmp->lines = lines;
if (lines != max_lines) {
+ if (lines >= INT32_MAX / sizeof *tmp->line)
+ lines = (INT32_MAX - 1) / sizeof *tmp->line; /* overflow */
size_t *d = (size_t *)realloc(tmp->line, lines * sizeof *tmp->line);
- if (lines == 0 || d != NULL) tmp->line = d;
+ if (lines == 0 || d != NULL)
+ tmp->line = d;
}
}
tmp->len = fp;