Re: type mismatch

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, 10 May 2015, Dan Carpenter wrote:

> I don't really have a strong opinion either way...  It's unlikely that
> we will introduce a bug here and if we did, I think it would be caught
> immediately in testing.
> 
> It's pretty common to treat the first member of a struct as special.
> What annoys me is when people do
> 
> struct foo {
> 	int one, two, three;
> 	whatever;
> };
> 
> memcpy(&foo.one, src, sizoef(struct foo));
> 
> Argh!?  These triger buffer overflows warnings in Smatch and I don't
> see the point since &foo.one is less readable than &foo!  Oh well, I
> think these were common enough, I had to treat it as idiomatic and add a
> special case for them.
>
just ran a naive scanner for that pattern but only could find this one instance

./net/sctp/sm_make_chunk.c:3103 ugly memset 
3102          if (af->is_any(&addr))
3103                  memcpy(&addr.v4, sctp_source(asconf), sizeof(addr));

my scanner ist:

@uses_first@
identifier f;
idexpression s;
identifier e;
position p;                                                                     
@@

f(...){
<+...
* memcpy@p(&s.e,...,sizeof(s));
...+>
}

@script:python@
p << uses_first.p;
@@
print "%s:%s ugly memset" % (p[0].file,p[0].line)

so is my scanner broken/incomplete or has this pattern lost its popularity ?

thx!
hofrat
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux