From: telephil9@gmail.com
To: 9front@9front.org
Cc: telephil9@gmail.com
Subject: [PATCH] fix APE sscanf [ specifier
Date: Thu, 7 May 2020 09:49:01 +0200 [thread overview]
Message-ID: <7BC56C4EE66212C553EFF6B020551A32@gmail.com> (raw)
Hi,
APE sscanf return value is wrong when using a [ specifier and there is no match.
The following code highlights the issue (full example: http://okturing.com/src/8478/body)
char s[2];
sscanf("H", " %1[Zz] ", s); // SHOULD NOT RETURN 1
This patch fixes the issue:
---
diff -r 8006152d13d2 sys/src/ape/lib/ap/stdio/vfscanf.c
--- a/sys/src/ape/lib/ap/stdio/vfscanf.c Tue Apr 28 20:51:19 2020 -0700
+++ b/sys/src/ape/lib/ap/stdio/vfscanf.c Thu May 07 09:44:39 2020 +0200
@@ -396,13 +396,14 @@
if(nn==0) return 0;
else goto Done;
}
- if(!match(c, pat))
- break;
+ if(!match(c, pat)){
+ nungetc(c, f);
+ return 0;
+ }
if(store)
*s++=c;
nn++;
}
- nungetc(c, f);
Done:
if(store) *s='\0';
return 1;
---
Regards,
Philippe
next reply other threads:[~2020-05-07 7:49 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-07 7:49 telephil9 [this message]
2020-05-07 16:24 ` telephil9
2020-05-08 15:11 ` [9front] " ori
2020-05-09 6:40 ` telephil9
2020-05-09 22:13 ` ori
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=7BC56C4EE66212C553EFF6B020551A32@gmail.com \
--to=telephil9@gmail.com \
--cc=9front@9front.org \
/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).