pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/gitgitgadget/git/commit/34736ff48e684dac08bacdad60db41219ce1c520

f82350aeda.css" /> Merge branch 'pw/apply-ulong-overflow-check' · gitgitgadget/git@34736ff · GitHub
Skip to content

Commit 34736ff

Browse files
committed
Merge branch 'pw/apply-ulong-overflow-check'
"git apply" internally uses unsigned long for line numbers and uses strtoul() to parse numbers on the hunk headers. It however forgot to check parse errors. * pw/apply-ulong-overflow-check: apply: detect overflow when parsing hunk header
2 parents 442b7e0 + a206058 commit 34736ff

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

apply.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1423,7 +1423,10 @@ static int parse_num(const char *line, unsigned long *p)
14231423

14241424
if (!isdigit(*line))
14251425
return 0;
1426+
errno = 0;
14261427
*p = strtoul(line, &ptr, 10);
1428+
if (errno)
1429+
return 0;
14271430
return ptr - line;
14281431
}
14291432

t/t4100-apply-stat.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,17 @@ incomplete (1)
3838
incomplete (2)
3939
EOF
4040

41+
test_expect_success 'applying a hunk header which overflows fails' '
42+
cat >patch <<-\EOF &&
43+
diff -u a/file b/file
44+
--- a/file
45+
+++ b/file
46+
@@ -98765432109876543210 +98765432109876543210 @@
47+
-a
48+
+b
49+
EOF
50+
test_must_fail git apply patch 2>err &&
51+
echo "error: corrupt patch at line 4" >expect &&
52+
test_cmp expect err
53+
'
4154
test_done

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy