|
From: Julian S. <js...@ac...> - 2003-11-03 14:45:01
|
CVS commit by jseward:
Merge revs
mac_replace_strmem.c 1.5
tests/overlap.c 1.3
Fixed bug in overlap check in strncpy() -- it was assuming the src was 'n'
bytes longs, when it could be shorter, which could cause false positives.
Added an example of this to the regtest.
M +6 -4 mac_replace_strmem.c 1.3.2.1
M +9 -0 tests/overlap.c 1.2.2.1
--- valgrind/memcheck/mac_replace_strmem.c #1.3:1.3.2.1
@@ -187,11 +187,13 @@ char* strcpy ( char* dst, const char* sr
char* strncpy ( char* dst, const char* src, int n )
{
+ const Char* src_orig = src;
Char* dst_orig = dst;
Int m = 0;
- if (is_overlap(dst, src, n, n))
- complain3("strncpy", dst, src, n);
-
while (m < n && *src) { m++; *dst++ = *src++; }
+ /* Check for overlap after copying; all n bytes of dst are relevant,
+ but only m+1 bytes of src if terminator was found */
+ if (is_overlap(dst_orig, src_orig, n, (m < n) ? m+1 : n))
+ complain3("strncpy", dst, src, n);
while (m++ < n) *dst++ = 0; /* must pad remainder with nulls */
--- valgrind/memcheck/tests/overlap.c #1.2:1.2.2.1
@@ -113,4 +113,13 @@ int main(void)
strncat(a, a+20, 21);
+ /* This is ok, but once gave a warning when strncpy() was wrong,
+ and used 'n' for the length, even when the src was shorter than 'n' */
+ {
+ char dest[64];
+ char src [16];
+ strcpy( src, "short" );
+ strncpy( dest, src, 20 );
+ }
+
return 0;
}
|
|
From: Nicholas N. <nj...@ca...> - 2003-12-02 10:22:31
|
CVS commit by nethercote:
Make --leak-check observe -q properly -- only prints out errors, not general
info and summaries.
M +23 -19 mac_leakcheck.c 1.7.2.2
M +0 -11 tests/nanoleak.stderr.exp 1.7.2.1
M +0 -11 tests/nanoleak_supp.stderr.exp 1.2.2.1
M +0 -11 tests/trivialleak.stderr.exp 1.6.2.1
--- valgrind/memcheck/mac_leakcheck.c #1.7.2.1:1.7.2.2
@@ -407,5 +407,7 @@ void MAC_(do_detect_memory_leaks) (
}
- VG_(message)(Vg_UserMsg, "searching for pointers to %d not-freed blocks.",
+ if (VG_(clo_verbosity) > 0)
+ VG_(message)(Vg_UserMsg,
+ "searching for pointers to %d not-freed blocks.",
lc_n_shadows );
@@ -427,4 +429,5 @@ void MAC_(do_detect_memory_leaks) (
);
+ if (VG_(clo_verbosity) > 0)
VG_(message)(Vg_UserMsg, "checked %d bytes.", bytes_notified);
@@ -512,4 +515,5 @@ void MAC_(do_detect_memory_leaks) (
}
+ if (VG_(clo_verbosity) > 0) {
VG_(message)(Vg_UserMsg, "");
VG_(message)(Vg_UserMsg, "LEAK SUMMARY:");
@@ -528,5 +532,5 @@ void MAC_(do_detect_memory_leaks) (
"To see them, rerun with: --show-reachable=yes");
}
- VG_(message)(Vg_UserMsg, "");
+ }
VG_(free) ( lc_shadows );
--- valgrind/memcheck/tests/nanoleak.stderr.exp #1.7:1.7.2.1
@@ -1,4 +1,2 @@
-searching for pointers to 1 not-freed blocks.
-checked ... bytes.
1000 bytes in 1 blocks are definitely lost in loss record 1 of 1
@@ -7,11 +5,2 @@
by 0x........: __libc_start_main (...libc...)
by 0x........: ...
-
-LEAK SUMMARY:
- definitely lost: 1000 bytes in 1 blocks.
- possibly lost: 0 bytes in 0 blocks.
- still reachable: 0 bytes in 0 blocks.
- suppressed: 0 bytes in 0 blocks.
-Reachable blocks (those to which a pointer was found) are not shown.
-To see them, rerun with: --show-reachable=yes
-
--- valgrind/memcheck/tests/nanoleak_supp.stderr.exp #1.2:1.2.2.1
@@ -1,11 +0,0 @@
-searching for pointers to 1 not-freed blocks.
-checked ... bytes.
-
-LEAK SUMMARY:
- definitely lost: 0 bytes in 0 blocks.
- possibly lost: 0 bytes in 0 blocks.
- still reachable: 0 bytes in 0 blocks.
- suppressed: 1000 bytes in 1 blocks.
-Reachable blocks (those to which a pointer was found) are not shown.
-To see them, rerun with: --show-reachable=yes
-
--- valgrind/memcheck/tests/trivialleak.stderr.exp #1.6:1.6.2.1
@@ -1,4 +1,2 @@
-searching for pointers to 1000 not-freed blocks.
-checked ... bytes.
1000 bytes in 1000 blocks are definitely lost in loss record 1 of 1
@@ -7,11 +5,2 @@
by 0x........: main (trivialleak.c:12)
by 0x........: __libc_start_main (...libc...)
-
-LEAK SUMMARY:
- definitely lost: 1000 bytes in 1000 blocks.
- possibly lost: 0 bytes in 0 blocks.
- still reachable: 0 bytes in 0 blocks.
- suppressed: 0 bytes in 0 blocks.
-Reachable blocks (those to which a pointer was found) are not shown.
-To see them, rerun with: --show-reachable=yes
-
|
|
From: Nicholas N. <nj...@ca...> - 2004-03-08 15:47:53
|
CVS commit by nethercote:
Remove warning with -q.
[from HEAD]
M +7 -5 mc_main.c 1.38.2.2
--- valgrind/memcheck/mc_main.c #1.38.2.1:1.38.2.2
@@ -288,4 +288,5 @@ static void set_address_range_perms ( Ad
return;
+ if (VG_(clo_verbosity) > 0) {
if (len > 100 * 1000 * 1000) {
VG_(message)(Vg_UserMsg,
@@ -294,4 +295,5 @@ static void set_address_range_perms ( Ad
len, example_a_bit, example_v_bit );
}
+ }
VGP_PUSHCC(VgpSetMem);
|