[PATCH] [sanitizer] Improve scanf interceptor
Evgeniy Stepanov
eugenis at google.com
Fri Feb 8 03:04:31 PST 2013
================
Comment at: sanitizer_common_interceptors_scanf.inc:85
@@ +84,3 @@
+ // Length modifier.
+ if (*p == 'j' || *p == 'z' || *p == 't' || *p == 'L' || *p == 'q') {
+ dir->lengthModifier[0] = *p;
----------------
Alexey Samsonov wrote:
> Evgeniy Stepanov wrote:
> > Alexey Samsonov wrote:
> > > Can you use smth like internal_strchr(*p, "jztLq") here and below?
> > It would be slow.
> I don't think that may be critical, but will improve readability.
fine
================
Comment at: sanitizer_common_interceptors_scanf.inc:130
@@ +129,3 @@
+static bool scanf_is_integer_conv(char c) {
+ return c == 'd' ||
+ c == 'i' ||
----------------
Alexey Samsonov wrote:
> strchr here as well
done
================
Comment at: sanitizer_common_interceptors_scanf.inc:140
@@ +139,3 @@
+static bool scanf_is_float_conv(char c) {
+ return c == 'a' || c == 'A' ||
+ c == 'e' || c == 'E' ||
----------------
Alexey Samsonov wrote:
> and here
done
================
Comment at: sanitizer_common_interceptors_scanf.inc:172
@@ +171,3 @@
+ if (scanf_is_integer_conv(dir->convSpecifier)) {
+ switch (dir->lengthModifier[0]) {
+ case 'h':
----------------
Alexey Samsonov wrote:
> Evgeniy Stepanov wrote:
> > Alexey Samsonov wrote:
> > > Why did you drop arrays of pairs { ('j', sizeof(INTMAX_T) , ... }?
> > This data does not tabulate well. We would have a special case for "hh" and "ll". And, anyway, it is used in one place only.
> Okay. But probably you can make code somewhat denser
> case 'j': return sizeof(INTMAX_T);
> case 'h': return (dir->lengthModifier[1] == 'h') ? sizeof(char) : sizeof(short);
> etc
This does not survive clang-format :)
I've switched to ?:, though.
http://llvm-reviews.chandlerc.com/D381
More information about the llvm-commits
mailing list