SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 838 | Next

Shon Harris, Allen Harper, Chris Eagle, and Jonathan Ness

"Gray Hat Hacking, Second Edition"

The three most common options to diff are
??? -a Causes diff to treat all files as text
??? -u Causes diff to generate output in ???unified??? format
??? -r Instructs diff to recursively descend into subdirectories
As an example, take a vulnerable program named rooted in a directory named hackable.
If we created a secure version of this program in a directory named hackable_not, we
could create a patch with the following diff command:
diff ??“aur hackable/ hackable_not/ > hackable.patch
The following output shows the differences in two files, example.c and example_fixed.c,
as generated by the following command:
# diff ??“au example.c example_fixed.c
--- example.c 2004-07-27 03:36:21.000000000 -0700
+++ example_fixed.c 2004-07-27 03:37:12.000000000 -0700
@@ -6,7 +6,8 @@
Gray Hat Hacking: The Ethical Hacker??™s Handbook
486
int main(int argc, char **argv) {
char buf[80];
- strcpy(buf, argv[0]);
+ strncpy(buf, argv[0], sizeof(buf));
+ buf[sizeof(buf) - 1] - 0;
printf("This program is named %s\n", buf);
}
The unified output format is used and indicates the files that have been compared, the
locations at which they differ, and the ways in which they differ. The important parts are
the lines prefixed with + and ??“.


Pages:
826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850