From: list at eworm.de (Christian Hesse)
Subject: [PATCH 3/3] move shared code to get_mimetype_from_file()
Date: Sat, 15 Aug 2015 22:12:43 +0200 [thread overview]
Message-ID: <20150815221243.4b8fe2c2@leda.localdomain> (raw)
In-Reply-To: <20150815112935.GC1412@serenity.lan>
John Keeping <john at keeping.me.uk> on Sat, 2015/08/15 12:29:
> > + /* loop over all lines in the file */
> > + while (!*mimetype && fgets(line, sizeof(line),
> > fd)) {
> > + iterate = strtok(line, delimiters);
> > +
> > + /* skip empty lines and comment lines */
> > + if (!iterate || (iterate[0] == '#'))
> > + continue;
> > +
> > + /* loop over all extensions of mimetype
> > */
> > + while ((token = strtok(NULL,
> > delimiters))) {
> > + if (!strcasecmp(ext, token)) {
> > + *mimetype = iterate;
>
> Doesn't this result in us reading stale memory in the caller?
> "iterate" derives from "line" which is on the stack.
This used to work, probably just as long as we do not call strtok() again. I
addressed that in my updated patches.
--
main(a){char*c=/* Schoene Gruesse */"B?IJj;MEH"
"CX:;",b;for(a/* Chris get my mail address: */=0;b=c[a++];)
putchar(b-1/(/* gcc -o sig sig.c && ./sig */b/42*2-3)*42);}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 473 bytes
Desc: OpenPGP digital signature
URL: <http://lists.zx2c4.com/pipermail/cgit/attachments/20150815/d43619c3/attachment-0001.asc>
next prev parent reply other threads:[~2015-08-15 20:12 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-14 14:50 [PATCH 1/2] move get_mimetype_from_file() to shared list
2015-08-14 14:50 ` [PATCH 2/2] about: send images plain list
2015-08-14 15:13 ` john
2015-08-14 21:16 ` [PATCH 2/3] " list
2015-08-14 21:16 ` [PATCH 3/3] move shared code to get_mimetype_from_file() list
2015-08-15 11:29 ` john
2015-08-15 20:12 ` list [this message]
2015-08-14 23:07 ` [PATCH 2/3] about: send images plain Jason
2015-08-15 20:10 ` list
2015-08-15 11:30 ` john
2015-08-15 20:08 ` [PATCH 2/3] refactor get_mimetype_from_file() to get_mimetype_from_qrypath() list
2015-08-15 20:08 ` [PATCH 3/3] ui-summary: send images plain for about page list
2015-08-16 12:19 ` [PATCH 2/3] refactor get_mimetype_from_file() to get_mimetype_from_qrypath() john
2015-08-16 12:51 ` list
2015-08-16 12:53 ` [PATCH 2/3] refactor get_mimetype_from_file() to get_mimetype_for_filename() list
2015-08-16 12:53 ` [PATCH 3/3] ui-summary: send images plain for about page list
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=20150815221243.4b8fe2c2@leda.localdomain \
--to=cgit@lists.zx2c4.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 NNTP newsgroup(s).