remote/2154: cached buffer pointers not updated after executing new getpkt

strauman@slac.stanford.edu strauman@slac.stanford.edu
Thu Aug 10 02:58:00 GMT 2006


>Number:         2154
>Category:       remote
>Synopsis:       cached buffer pointers not updated after executing new getpkt
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Aug 10 02:58:01 GMT 2006
>Closed-Date:
>Last-Modified:
>Originator:     Till Straumann
>Release:        6.5
>Organization:
>Environment:

>Description:
At many places in remote.c the buffer pointer is cached

char *buf = rs->buf;

but not updated after executing getpkt(&rs->buf,...).
If rs->buf is ever reallocated then the cached pointer
is invalid.
>How-To-Repeat:

>Fix:
attached. I did this quickly, someone should review...
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/x-patch; name="remote.c-update-cached-bufptrs.diff"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="remote.c-update-cached-bufptrs.diff"

KioqIHJlbW90ZS5jLm9yaWcJMjAwNi0wNS0wNSAxMzowODo0NS4wMDAwMDAwMDAgLTA3MDAKLS0t
IHJlbW90ZS5jCTIwMDYtMDgtMDkgMTk6NTE6MTcuMDAwMDAwMDAwIC0wNzAwCioqKioqKioqKioq
KioqKgoqKiogOTI3LDkzMiAqKioqCi0tLSA5MjcsOTMzIC0tLS0KICAgICAgeHNucHJpbnRmICgm
YnVmWzJdLCBycy0+cmVtb3RlX3BhY2tldF9zaXplIC0gMiwgIiV4IiwgdGgpOwogICAgcHV0cGt0
IChidWYpOwogICAgZ2V0cGt0ICgmcnMtPmJ1ZiwgJnJzLT5idWZfc2l6ZSwgMCk7CisgICBidWYg
PSBycy0+YnVmOwogICAgaWYgKGdlbikKICAgICAgZ2VuZXJhbF90aHJlYWQgPSB0aDsKICAgIGVs
c2UKKioqKioqKioqKioqKioqCioqKiA5NDgsOTUzICoqKioKLS0tIDk0OSw5NTUgLS0tLQogICAg
ICB4c25wcmludG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
XSA9PSAnXDAnKQogIAllcnJvciAoXygiVGFyZ2V0IGRvZXMgbm90IHN1cHBvcnQgdGhpcyBjb21t
YW5kLiIpKTsKICAgICAgICBpZiAoYnVmWzBdID09ICdPJyAmJiBidWZbMV0gIT0gJ0snKQo=



More information about the Gdb-prs mailing list