From 3101ea517df936843d1addc30d5f4da9f9a05e99 Mon Sep 17 00:00:00 2001 From: Richard Jones Date: Wed, 12 May 2010 16:55:59 +0100 Subject: [PATCH] Fix error message in strings-e command (RHBZ#588651). (cherry picked from commit 287f8957fea3efe411c7ac55595d5d6c7b613e4e and modified to apply to the stable branch. Note that the original commit message contains a typo 'string-e' instead of 'strings-e') --- daemon/strings.c | 6 ++++++ src/generator.ml | 37 +++++++++++++++++++++++++++++++++---- 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/daemon/strings.c b/daemon/strings.c index 4701716..778aea3 100644 --- a/daemon/strings.c +++ b/daemon/strings.c @@ -33,6 +33,12 @@ do_strings_e (const char *encoding, const char *path) char *out, *err; char **lines; + if (strlen (encoding) != 1 || + strchr ("sSblBL", encoding[0]) == NULL) { + reply_with_error ("%s: invalid encoding", encoding); + return NULL; + } + buf = sysroot_path (path); if (!buf) { reply_with_perror ("malloc"); diff --git a/src/generator.ml b/src/generator.ml index 68b25e0..986b0c5 100755 --- a/src/generator.ml +++ b/src/generator.ml @@ -2442,12 +2442,41 @@ the list of printable strings found."); "print the printable strings in a file", "\ This is like the C command, but allows you to -specify the encoding. +specify the encoding of strings that are looked for in +the source file C. -See the L manpage for the full list of encodings. +Allowed encodings are: -Commonly useful encodings are C (lower case L) which will -show strings inside Windows/x86 files. +=over 4 + +=item s + +Single 7-bit-byte characters like ASCII and the ASCII-compatible +parts of ISO-8859-X (this is what C uses). + +=item S + +Single 8-bit-byte characters. + +=item b + +16-bit big endian strings such as those encoded in +UTF-16BE or UCS-2BE. + +=item l (lower case letter L) + +16-bit little endian such as UTF-16LE and UCS-2LE. +This is useful for examining binaries in Windows guests. + +=item B + +32-bit big endian such as UCS-4BE. + +=item L + +32-bit little endian such as UCS-4LE. + +=back The returned strings are transcoded to UTF-8."); -- 1.8.3.1