From: erik quanstrom <quanstro@quanstro.net>
To: 9fans@9fans.net
Subject: Re: [9fans] dial and buffer overflow
Date: Sat, 4 Jul 2009 20:36:56 -0400 [thread overview]
Message-ID: <07da045134936f2ff61916ea6b5b3711@quanstro.net> (raw)
In-Reply-To: <24db968438c83ecd8b9573681c244a0b@smgl.fr.eu.org>
On Sat Jul 4 18:12:16 EDT 2009, lejatorn@gmail.com wrote:
> Thanks for the answer Erik.
>
> [...]
> > the extra () around tor->sha1list are confusing.
>
> Noted, thanks, they're gone. I suck at remembering operators precedence
> so I usually add a few parentheses to be on the safe side.
i think it's important to learn operator precedence.
why guess when you can know? you can steal
the cheet sheet i stole from bwc:
#! /bin/rc
label prec
cat <<!
left to right () [] -> .
right to left ! ~ ++ -- - (type) * & sizeof
left to right * / %
left to right + -
left to right << >>
left to right < <= > >=
left to right == !=
left to right &
left to right ^
left to right |
left to right &&
left to right ||
right to left ?:
right to left = += -= etc.
left to right ,
!
> > the three most common errors that cause this are
> > (a) not allocating enough memory by, e.g.
> > malloc(sizeof tor) not malloc(sizeof *tor). or
> > (b) pointing to a non-static on the stack,
> > or (c) mistyping of tor->sha1list so that sizeof
> > tor->sha1list[0][0] != 1.
>
> Could you elaborate on (b), or point me to an example please? I don't
> really understand what it means or how it could happen...
generally, it's not so obvious, but a variation of this
would do it:
uchar*
badfn(char *txt, uint len)
{
uchar buf[SHA1dlen];
sha1(txt, len, sha, nil);
return buf;
}
- erik
prev parent reply other threads:[~2009-07-05 0:36 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-04 15:43 Mathieu L.
2009-07-04 20:43 ` erik quanstrom
2009-07-04 22:11 ` Mathieu L.
2009-07-05 0:36 ` erik quanstrom [this message]
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=07da045134936f2ff61916ea6b5b3711@quanstro.net \
--to=quanstro@quanstro.net \
--cc=9fans@9fans.net \
/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 NNTP newsgroup(s).