debian/0000755000000000000000000000000011725013204007161 5ustar debian/tweak.docs0000644000000000000000000000001311725005122011140 0ustar btree.html debian/watch0000644000000000000000000000027011725005122010211 0ustar # See uscan(1) for format # Compulsory line, this is a version 3 file version=3 # http://www.chiark.greenend.org.uk/~sgtatham/tweak/ tweak-(.*)\.tar\.gz debian/rules0000755000000000000000000000036711725012123010246 0ustar #!/usr/bin/make -f %: dh $@ override_dh_auto_install: $(MAKE) install PREFIX=$(CURDIR)/debian/tweak/usr MANDIR=$(CURDIR)/debian/tweak/usr/share/man/man1 # upstream's clean target is overly-destructive. override_dh_auto_clean: rm -f *.o tweak debian/README.source0000644000000000000000000000274311725005122011346 0ustar This package uses dpatch to manage all modifications to the upstream source. Changes are stored in the source package as diffs in debian/patches and applied during the build. To get the fully patched source after unpacking the source package, cd to the root level of the source package and run: debian/rules patch Removing a patch is as simple as removing its entry from the debian/patches/00list file, and please also remove the patch file itself. Creating a new patch is done with "dpatch-edit-patch patch XX_patchname" where you should replace XX with a new number and patchname with a descriptive shortname of the patch. You can then simply edit all the files your patch wants to edit, and then simply "exit 0" from the shell to actually create the patch file. To tweak an already existing patch, call "dpatch-edit-patch XX_patchname" and replace XX_patchname with the actual filename from debian/patches you want to use. To clean up afterwards again, "debian/rules unpatch" will do the work for you - or you can of course choose to call "fakeroot debian/rules clean" all together. --- this documentation is part of dpatch package, and may be used by packages using dpatch to comply with policy on README.source. This documentation is meant to be useful to users who are not proficient in dpatch in doing work with dpatch-based packages. Please send any improvements to the BTS of dpatch package. original text by Gerfried Fuchs, edited by Junichi Uekawa 10 Aug 2008. debian/menu0000644000000000000000000000017511725005122010053 0ustar ?package(tweak):needs="text" hints="Expert" section="Applications/Editors"\ title="tweak" command="/usr/bin/tweak-wrapper" debian/control0000644000000000000000000000156511725012751010601 0ustar Source: tweak Section: editors Priority: extra Maintainer: Daniel Kahn Gillmor Build-Depends: debhelper (>= 8), libncurses5-dev Vcs-Git: git://lair.fifthhorseman.net/~dkg/tweak Homepage: http://www.chiark.greenend.org.uk/~sgtatham/tweak/ Standards-Version: 3.9.3 Package: tweak Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends} Description: Efficient text-mode hex editor Tweak is a hex editor. It allows you to edit a file at very low level, letting you see the full and exact binary contents of the file. It can be useful for modifying binary files such as executables, editing disk or CD images, debugging programs that generate binary file formats incorrectly, and many other things. . Tweak runs under any terminal emulator using the curses library. It has customizable keybindings, but the default keybindings are similar to emacs. debian/changelog0000644000000000000000000000513011725013117011035 0ustar tweak (3.01-8) unstable; urgency=low * debian/control: bump Standards-Version to 3.9.3 (no changes needed), change Vcs- fields. * debian/rules: minimize, move to dh 8 * convert source format to '3.0 (quilt)' (dropping dpatch build-dep) * drop halibut build-dep in favor of shipping upstream's man page and documentation directly. -- Daniel Kahn Gillmor Sun, 04 Mar 2012 19:37:53 -0500 tweak (3.01-7) unstable; urgency=low * Debian Packaging cleanup: - updated my e-mail address - moved to debhelper 7, minimized debian/rules - debian/control: remove XS- from Dm-Upload-Allowed - bumped policy to 3.8.1 (added README.source explaining dpatch) - copyright for debian packaging now references GPL-3 explicitly -- Daniel Kahn Gillmor Mon, 30 Mar 2009 03:14:14 -0400 tweak (3.01-6) unstable; urgency=low * avoided common opportunities for buffer overflows (Closes: #469966). * switched doc-base section for tweak-btree to Programming. -- Daniel Kahn Gillmor Sun, 16 Mar 2008 20:09:36 -0400 tweak (3.01-5) unstable; urgency=low * Adding upstream's svn r7478 to fix crashes with weird terminal sizes as root (Closes: #464628) -- Daniel Kahn Gillmor Mon, 11 Feb 2008 23:51:46 -0500 tweak (3.01-4) unstable; urgency=low * added XS-Dm-Upload-Allowed:, Homepage:, Vcs-Browser: Vcs-Svn: fields to debian/control * changed debian packaging license to GPL v3 or later * update standards version to 3.7.3 (changed menu) -- Daniel Kahn Gillmor Wed, 05 Dec 2007 00:14:35 -0500 tweak (3.01-3) unstable; urgency=low * switched to using dh_install and dh_links. * removed Rafael Laboissiere from Uploaders, since he's just the sponsor and not a co-maintainer. * added doc-base to index Simon's btree.html -- Daniel Kahn Gillmor Thu, 15 Mar 2007 14:59:41 -0400 tweak (3.01-2) unstable; urgency=low * removed debian/dirs * cleaned up debian/rules and added proper copyright/license * debian/control: added rafael to uploaders, dropped ${misc:Depends}, properly formatted URL and added another short paragraph. * fixed up menu entry with tweak-wrapper * added btree.html to docs * thanks, Rafael Laboissiere! -- Daniel Kahn Gillmor Wed, 14 Mar 2007 15:50:31 -0400 tweak (3.01-1) unstable; urgency=low * Initial release (Closes: #414844) -- Daniel Kahn Gillmor Tue, 13 Mar 2007 21:44:07 -0400 debian/copyright0000644000000000000000000000276011725005122011121 0ustar This package was debianized by Daniel Kahn Gillmor on Tue, 13 Mar 2007 21:44:07 -0400. It was downloaded from http://www.chiark.greenend.org.uk/~sgtatham/tweak/ Upstream Author: Simon Tatham Copyright: 1994-2007 Simon Tatham License: tweak is distributed with an MIT-style license: Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. The Debian packaging is © 2007-2009, Daniel Kahn Gillmor and is licensed under the GPL v3 or later, see `/usr/share/common-licenses/GPL-3'. debian/compat0000644000000000000000000000000211725005542010365 0ustar 8 debian/tweak-wrapper0000755000000000000000000000057611725005122011710 0ustar #!/usr/bin/perl -w # suggested by Rafael Laboissiere my $file; if (eval "require Curses::UI") { my $cui = new Curses::UI (-clear_on_exit => 1); $file = $cui -> loadfilebrowser ( -title => "Select file to edit with tweak", -editfilename => 1, ); } else { print "tweak file: "; $file = ; } exec "/usr/bin/tweak $file"; debian/patches/0000755000000000000000000000000011725012565010621 5ustar debian/patches/01_fix_464628_with_svn_74780000644000000000000000000000241211725005122015067 0ustar #! /bin/sh /usr/share/dpatch/dpatch-run ## 01_fix_464628_with_svn_7478.dpatch by Daniel Kahn Gillmor ## ## All lines beginning with `## DP:' are a description of the patch. ## DP: Fix odd terminal size crash as superuser. ## DP: fixes #464628 (pulled from upstream SVN r7478) @DPATCH@ --- tweak/main.c (revision 7477) +++ tweak/main.c (revision 7478) @@ -469,7 +469,7 @@ } static unsigned char *scrbuf = NULL; -static int scrbuflines = 0; +static int scrbufsize = 0; /* * Draw the screen, for normal usage. @@ -484,16 +484,15 @@ char *linebuf; scrlines = display_rows - 2; - if (scrlines > scrbuflines) { - scrbuf = (scrbuf ? - realloc(scrbuf, scrlines*width) : - malloc(scrlines*width)); + scrsize = scrlines * width; + if (scrsize > scrbufsize) { + scrbuf = (scrbuf ? realloc(scrbuf, scrsize) : malloc(scrsize)); if (!scrbuf) { done(); fprintf(stderr, "%s: out of memory!\n", pname); exit (2); } - scrbuflines = scrlines; + scrbufsize = scrsize; } linebuf = malloc(width*4+20); @@ -509,7 +508,8 @@ scroff = width - offset; else scroff = 0; - scrsize = scrlines * width - scroff; + + scrsize -= scroff; if (scrsize > file_size - top_pos) scrsize = file_size - top_pos; debian/patches/series0000644000000000000000000000006611725005122012027 0ustar 01_fix_464628_with_svn_7478 02_avoid_buffer_overflows debian/patches/02_avoid_buffer_overflows0000755000000000000000000003000111725005122015572 0ustar #! /bin/sh /usr/share/dpatch/dpatch-run ## 02_avoid_buffer_overflows.dpatch by Daniel Kahn Gillmor ## ## All lines beginning with `## DP:' are a description of the patch. ## DP: Cleaning up all strcpy, strcat, and sprintf invocations to avoid ## DP: common buffer overflows at least. @DPATCH@ diff -urNad tweak~/actions.c tweak/actions.c --- tweak~/actions.c 2007-03-14 00:42:05.000000000 -0400 +++ tweak/actions.c 2008-03-16 20:06:29.796165664 -0400 @@ -139,14 +139,14 @@ if (!backed_up) { if (!backup_file()) { display_beep(); - strcpy (message, "Unable to back up file!"); + strncpy (message, "Unable to back up file!", sizeof(message) - 1); return; } backed_up = TRUE; } if (!save_file()) { display_beep(); - strcpy (message, "Unable to save file!"); + strncpy (message, "Unable to save file!", sizeof(message) - 1); return; } modified = FALSE; @@ -292,7 +292,7 @@ static void act_togins(void) { if (look_mode || fix_mode) { display_beep(); - sprintf(message, "Can't engage Insert mode when in %s mode", + snprintf(message, sizeof(message), "Can't engage Insert mode when in %s mode", (look_mode ? "LOOK" : "FIX")); insert_mode = FALSE; /* safety! */ } else @@ -312,7 +312,7 @@ if (look_mode) { display_beep(); - strcpy (message, "Can't modify file in LOOK mode"); + strncpy (message, "Can't modify file in LOOK mode", sizeof(message - 1)); return; } @@ -325,14 +325,14 @@ last_char -= 'a'-10; else { display_beep(); - strcpy(message, "Not a valid character when in hex editing mode"); + strncpy(message, "Not a valid character when in hex editing mode", sizeof(message) - 1); return; } } if ( (!insert || edit_type == 2) && cur_pos == file_size) { display_beep(); - strcpy(message, "End of file reached"); + strncpy(message, "End of file reached", sizeof(message) - 1); return; } @@ -365,7 +365,7 @@ modified = TRUE; } else { display_beep(); - strcpy(message, "End of file reached"); + strncpy(message, "End of file reached", sizeof(message) - 1); } act_right(); } @@ -373,7 +373,7 @@ static void act_delete(void) { if (!insert_mode || (edit_type!=2 && cur_pos==0)) { display_beep(); - strcpy (message, "Can't delete while not in Insert mode"); + strncpy (message, "Can't delete while not in Insert mode", sizeof(message) - 1); } else if (cur_pos > 0 || edit_type == 2) { act_left(); buf_delete (filedata, 1, cur_pos); @@ -386,7 +386,7 @@ static void act_delch(void) { if (!insert_mode) { display_beep(); - strcpy (message, "Can't delete while not in Insert mode"); + strncpy (message, "Can't delete while not in Insert mode", sizeof(message) - 1); } else if (cur_pos < file_size) { buf_delete (filedata, 1, cur_pos); file_size--; @@ -398,7 +398,7 @@ static void act_mark (void) { if (look_mode) { display_beep(); - strcpy (message, "Can't cut or paste in LOOK mode"); + strncpy (message, "Can't cut or paste in LOOK mode", sizeof(message) - 1); marking = FALSE; /* safety */ return; } @@ -411,12 +411,12 @@ if (!marking || mark_point==cur_pos) { display_beep(); - strcpy (message, "Set mark first"); + strncpy (message, "Set mark first", sizeof(message) - 1); return; } if (!insert_mode) { display_beep(); - strcpy (message, "Can't cut while not in Insert mode"); + strncpy (message, "Can't cut while not in Insert mode", sizeof(message) - 1); return; } marktop = cur_pos; @@ -444,7 +444,7 @@ if (!marking) { display_beep(); - strcpy (message, "Set mark first"); + strncpy (message, "Set mark first", sizeof(message) - 1); return; } marktop = cur_pos; @@ -466,7 +466,7 @@ if (!insert_mode) { if (cur_pos + cutsize > file_size) { display_beep(); - strcpy (message, "Too close to end of file to paste"); + strncpy (message, "Too close to end of file to paste", sizeof(message) - 1); return; } buf_delete (filedata, cutsize, cur_pos); @@ -500,13 +500,13 @@ position = parse_num (buffer, &error); if (error) { display_beep(); - strcpy (message, "Unable to parse position value"); + strncpy (message, "Unable to parse position value", sizeof(message) - 1); return; } if (position < 0 || position > file_size) { display_beep(); - strcpy (message, "Position is outside bounds of file"); + strncpy (message, "Position is outside bounds of file", sizeof(message) - 1); return; } @@ -537,7 +537,7 @@ if (!get_str(last_search ? withdef : withoutdef, buffer, TRUE)) return 0; /* user break */ if (!last_search && !*buffer) { - strcpy (message, "Search aborted."); + strncpy (message, "Search aborted.", sizeof(message) - 1); return 0; } @@ -547,7 +547,7 @@ len = parse_quoted (buffer); if (len == -1) { display_beep(); - strcpy (message, "Invalid escape sequence in search string"); + strncpy (message, "Invalid escape sequence in search string", sizeof(message) - 1); return 0; } if (last_search) @@ -597,7 +597,7 @@ } } } - strcpy (message, "Not found."); + strncpy (message, "Not found.", sizeof(message) - 1); } static void act_search_backwards (void) { @@ -643,7 +643,7 @@ } } } - strcpy (message, "Not found."); + strncpy (message, "Not found.", sizeof(message) - 1); } static void act_recentre (void) { @@ -660,13 +660,13 @@ fileoffset_t new_top; int error; - sprintf (prompt, "Enter screen width in bytes (now %"OFF"d): ", width); + snprintf (prompt, sizeof(prompt), "Enter screen width in bytes (now %"OFF"d): ", width); if (!get_str (prompt, buffer, FALSE)) return; w = parse_num (buffer, &error); if (error) { display_beep(); - strcpy (message, "Unable to parse width value"); + strncpy (message, "Unable to parse width value", sizeof(message) - 1); return; } if (w > 0) { @@ -686,14 +686,14 @@ fileoffset_t new_top; int error; - sprintf (prompt, "Enter start-of-file offset in bytes (now %"OFF"d): ", + snprintf (prompt, sizeof(prompt), "Enter start-of-file offset in bytes (now %"OFF"d): ", realoffset); if (!get_str (prompt, buffer, FALSE)) return; o = parse_num (buffer, &error); if (error) { display_beep(); - strcpy (message, "Unable to parse offset value"); + strncpy (message, "Unable to parse offset value", sizeof(message) - 1); return; } if (o >= 0) { diff -urNad tweak~/keytab.c tweak/keytab.c --- tweak~/keytab.c 2007-03-14 00:42:05.000000000 -0400 +++ tweak/keytab.c 2008-03-16 20:06:29.796165664 -0400 @@ -60,17 +60,18 @@ /* * Format an ASCII code into a printable description of the key stroke. + * should use no more than 8 chars -- make sure s has room for 8 chars! */ static void strkey (char *s, int k) { k &= 255; /* force unsigned */ if (k==27) - strcpy(s, " ESC"); + strncpy(s, " ESC", 8); else if (k<32 || k==127) - sprintf(s, " ^%c", k ^ 64); + snprintf(s, 8, " ^%c", k ^ 64); else if (k<127) - sprintf(s, " %c", k); + snprintf(s, 8, " %c", k); else - sprintf(s, " <0x%2X>", k); + snprintf(s, 8, " <0x%2X>", k); } /* @@ -88,7 +89,7 @@ #if defined(unix) && !defined(GO32) safe_update = FALSE; #endif - strcpy(message, "Unknown key sequence"); + strncpy(message, "Unknown key sequence", sizeof(message)); strkey(message+strlen(message), last_char); kt = base[(unsigned char) last_char]; if (!kt) { diff -urNad tweak~/main.c tweak/main.c --- tweak~/main.c 2008-03-16 20:06:29.296137168 -0400 +++ tweak/main.c 2008-03-16 20:06:29.796165664 -0400 @@ -318,7 +318,7 @@ void fix_offset(void) { if (3*width+11 > display_cols) { width = (display_cols-11) / 3; - sprintf (message, "Width reduced to %"OFF"d to fit on the screen", width); + snprintf (message, sizeof(message), "Width reduced to %"OFF"d to fit on the screen", width); } if (4*width+14 > display_cols) { ascii_enabled = FALSE; @@ -347,7 +347,7 @@ display_define_colour(COL_INVALID, 11, 0, FALSE); for (i=0; i<256; i++) { - sprintf(hex[i], "%02X", i); + snprintf(hex[i], 3, "%02X", i); toprint[i] = (i>=32 && i<127 ? i : '.'); } } @@ -384,12 +384,12 @@ } fclose (fp); assert(file_size == buf_length(filedata)); - sprintf(message, "loaded %s (size %"OFF"d == 0x%"OFF"X).", + snprintf(message, sizeof(message), "loaded %s (size %"OFF"d == 0x%"OFF"X).", fname, file_size, file_size); } else { filedata = buf_new_from_file(fp); file_size = buf_length(filedata); - sprintf(message, "opened %s (size %"OFF"d == 0x%"OFF"X).", + snprintf(message, sizeof(message), "opened %s (size %"OFF"d == 0x%"OFF"X).", fname, file_size, file_size); } new_file = FALSE; @@ -400,7 +400,7 @@ exit (1); } filedata = buf_new_empty(); - sprintf(message, "New file %s.", fname); + snprintf(message, sizeof(message), "New file %s.", fname); new_file = TRUE; } } @@ -445,9 +445,10 @@ if (new_file) return TRUE; /* unnecessary - pretend it's done */ - strcpy (backup_name, filename); + backup_name[sizeof(backup_name) - 1] = '\0'; /* ensure null termination */ + strncpy (backup_name, filename, sizeof(backup_name) - 1); #if defined(unix) && !defined(GO32) - strcat (backup_name, ".bak"); + strncat (backup_name, ".bak", sizeof(backup_name) - (strlen(backup_name) + 1)); #elif defined(MSDOS) { char *p, *q; @@ -605,7 +606,7 @@ int slen; display_moveto (display_rows-2, 0); display_set_colour(COL_STATUS); - sprintf(status, statfmt, + snprintf(status, sizeof(status), statfmt, (modified ? "**" : " "), filename, (insert_mode ? "(Insert)" : @@ -691,7 +692,7 @@ } else if (c == 27 || c == 7) { display_beep(); display_post_error(); - strcpy (message, "User Break!"); + strncpy (message, "User Break!", sizeof(message)); return FALSE; } @@ -760,7 +761,7 @@ init(); #else display_beep(); - strcpy(message, "Suspend function not yet implemented."); + strncpy(message, "Suspend function not yet implemented.", sizeof(message)); #endif } diff -urNad tweak~/rcfile.c tweak/rcfile.c --- tweak~/rcfile.c 2007-03-14 00:42:05.000000000 -0400 +++ tweak/rcfile.c 2008-03-16 20:08:05.301608209 -0400 @@ -148,11 +148,12 @@ int lineno = 0; int errors = FALSE, errors_here; + rcname[sizeof(rcname) - 1] = '\0'; /* ensure null termination */ #if defined(unix) && !defined(GO32) rcname[0] = '\0'; if (getenv("HOME")) - strcpy (rcname, getenv("HOME")); - strcat (rcname, "/.tweakrc"); + strncpy (rcname, getenv("HOME"), sizeof(rcname) - 1); + strncat (rcname, "/.tweakrc", sizeof(rcname) - (1 + strlen(rcname))); #elif defined(MSDOS) /* * Use environment variable TWEAKRC if set. Otherwise, look for @@ -160,19 +161,19 @@ * and failing everything else, try C:\TWEAK\TWEAK.RC. */ if (getenv("TWEAKRC")) - strcpy (rcname, getenv("TWEAKRC")); + strncpy (rcname, getenv("TWEAKRC"), sizeof(rcname) - 1); else { if ( (q = strrchr(pname, '\\')) != NULL) { FILE *tempfp; strncpy (rcname, pname, q+1-pname); - strcpy (rcname+(q+1-pname), "TWEAK.RC"); + strncpy (rcname+(q+1-pname), "TWEAK.RC", sizeof(rcname) - (2+q-pname)); if ( (tempfp = fopen(rcname, "r")) != NULL) fclose (tempfp); else - strcpy (rcname, "C:\\TWEAK\\TWEAK.RC"); + strncpy (rcname, "C:\\TWEAK\\TWEAK.RC", sizeof(rcname-1)); } else - strcpy (rcname, "C:\\TWEAK\\TWEAK.RC"); + strncpy (rcname, "C:\\TWEAK\\TWEAK.RC", sizeof(rcname-1)); } #endif @@ -197,7 +198,7 @@ } else { if (!*p) break; - strcpy (rcbuffer, *p++); + strncpy (rcbuffer, *p++, sizeof(rcbuffer)); } lineno++; errors_here = FALSE; diff -urNad tweak~/slang.c tweak/slang.c --- tweak~/slang.c 2007-03-14 00:42:05.000000000 -0400 +++ tweak/slang.c 2008-03-16 20:06:29.796165664 -0400 @@ -125,7 +125,7 @@ bg = 0; } - sprintf(cname, "colour%d", colour); + snprintf(cname, sizeof(cname), "colour%d", colour); SLtt_set_color(colour, cname, colours[fg], colours[bg]); } debian/source/0000755000000000000000000000000011725012451010464 5ustar debian/source/format0000644000000000000000000000001411725012451011672 0ustar 3.0 (quilt) debian/gbp.conf0000644000000000000000000000012111725006226010600 0ustar [DEFAULT] upstream-tag = tweak_%(version)s debian-tag = tweak_debian/%(version)s debian/doc-base0000644000000000000000000000076111725005122010565 0ustar Document: tweak-btree Title: An Efficient Data Structure For A Hex Editor Author: Simon Tatham Abstract: Good, flexible hex editors need to be able to work with very large files. They should also be able to operate in both insert and overwrite modes. This article presents an efficient and scalable data structure which supports all the operations needed by a such a hex editor. Section: Programming Format: html Index: /usr/share/doc/tweak/btree.html Files: /usr/share/doc/tweak/btree.html debian/install0000644000000000000000000000003511725005122010550 0ustar debian/tweak-wrapper usr/bin debian/links0000644000000000000000000000007711725005122010230 0ustar usr/share/man/man1/tweak.1 usr/share/man/man1/tweak-wrapper.1