Skip to content

Commit

Permalink
tcp: prevent invalid mem access
Browse files Browse the repository at this point in the history
Reported by Saúl Ibarra Corretgé
  • Loading branch information
razvancrainea committed Mar 4, 2016
1 parent 6d1704c commit a607aa8
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions net/proto_tcp/tcp_common.h
Expand Up @@ -421,11 +421,15 @@ static inline int tcp_handle_req(struct tcp_req *req,
}
}

*req->parsed=c;

update_stat( pt[process_no].load, -1 );

if (size) memmove(req->buf, req->parsed, size);
if (size) {
/* restoring the char only makes sense if there is something else to
* process, otherwise we can leave it. This prevents us from accessing
* unallocated memory - razvanc */
*req->parsed=c;
memmove(req->buf, req->parsed, size);
}
#ifdef EXTRA_DEBUG
LM_DBG("preparing for new request, kept %ld bytes\n", size);
#endif
Expand Down

0 comments on commit a607aa8

Please sign in to comment.