From: Ben Elliston <bje@redhat.com>
To: sid@sources.redhat.com
Subject: [RFA] cfgroot usability improvement
Date: Sun, 20 May 2001 21:12:00 -0000 [thread overview]
Message-ID: <15112.38243.488724.630625@scooby.apac.redhat.com> (raw)
The following patch handles the case whereby foolish users (me!) run
sid on a binary file (foo.x) instead of its corresponding
configuration file (foo.x.conf). If too many non-printable characters
are detected in the input file, sid will stop.
Okay to commit?
2001-05-21 Ben Elliston <bje@redhat.com>
* compConfig.cxx (cfgroot_component::num_invalid_chars): New.
(cfgroot_component ctor): Initialise it.
(cfgroot_component::consume_token): If num_invalid_chars exceeds
5, emit an error message and stop.
Index: compConfig.cxx
===================================================================
RCS file: /cvs/cvsfiles/devo/sid/component/cfgroot/compConfig.cxx,v
retrieving revision 1.77
diff -u -c -r1.77 compConfig.cxx
*** compConfig.cxx 2001/03/26 19:18:38 1.77
--- compConfig.cxx 2001/05/21 04:09:15
***************
*** 107,112 ****
--- 107,113 ----
unsigned line_num;
bool parse(istream&);
string current_token;
+ int num_invalid_chars;
void consume_token(istream&);
string next_token(istream&);
bool parse_command(istream&);
***************
*** 255,260 ****
--- 256,266 ----
{
if (!isprint(ch))
{
+ if (++num_invalid_chars > 5)
+ {
+ emit_error ("too many invalid characters--possibly a binary file?");
+ exit (1);
+ }
emit_error(string("invalid character [") +
make_numeric_attribute(host_int_2((unsigned char) ch),
ios::hex|ios::showbase) +
***************
*** 273,278 ****
--- 279,289 ----
}
else // control code
{
+ if (++num_invalid_chars > 5)
+ {
+ emit_error ("too many invalid characters--possibly a binary file?");
+ exit (1);
+ }
emit_error(string("invalid character [") +
make_numeric_attribute(host_int_2((unsigned char) ch),
ios::hex|ios::showbase) +
***************
*** 545,551 ****
stop_pin(this, & cfgroot_component::stop),
verbose_p (false),
autoprint_p (true),
! persistent_p (false)
{
// suck in libtool preloaded symbols; must be called before lt_dlinit()
LTDL_SET_PRELOADED_SYMBOLS ();
--- 556,563 ----
stop_pin(this, & cfgroot_component::stop),
verbose_p (false),
autoprint_p (true),
! persistent_p (false),
! num_invalid_chars (0)
{
// suck in libtool preloaded symbols; must be called before lt_dlinit()
LTDL_SET_PRELOADED_SYMBOLS ();
next reply other threads:[~2001-05-20 21:12 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-05-20 21:12 Ben Elliston [this message]
2001-05-21 6:28 ` Frank Ch. Eigler
2001-05-22 1:46 ` Ben Elliston
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=15112.38243.488724.630625@scooby.apac.redhat.com \
--to=bje@redhat.com \
--cc=sid@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).