aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Szeredi <miklos@szeredi.hu>2005-10-17 12:57:52 +0000
committerMiklos Szeredi <miklos@szeredi.hu>2005-10-17 12:57:52 +0000
commit0358c96422e74786ec03b914baab4195e38a50f5 (patch)
tree0982f87391e62b4c6bca70c5f52bce17407c800e
parent205f9ac27ecdceb6f99fbef806328265e8293bac (diff)
downloadsshfs-0358c96422e74786ec03b914baab4195e38a50f5.tar
sshfs-0358c96422e74786ec03b914baab4195e38a50f5.tar.gz
sshfs-0358c96422e74786ec03b914baab4195e38a50f5.tar.bz2
sshfs-0358c96422e74786ec03b914baab4195e38a50f5.zip
fix
-rw-r--r--ChangeLog5
-rw-r--r--sshfs.c10
2 files changed, 10 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index ed75569..fe5fd32 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2005-10-15 Miklos Szeredi <miklos@szeredi.hu>
+
+ * Protect request ID allocation with mutex. Bug report by Tvrtko
+ Ursulin
+
2005-08-17 Miklos Szeredi <miklos@szeredi.hu>
* Try to calculate approximate disk usage of files from their
diff --git a/sshfs.c b/sshfs.c
index 53b0ea3..eca3369 100644
--- a/sshfs.c
+++ b/sshfs.c
@@ -933,13 +933,9 @@ static int sftp_request_common(uint8_t type, const struct buffer *buf,
{
int err;
struct buffer buf2;
- uint32_t id = sftp_get_id();
+ uint32_t id;
struct request *req = g_new0(struct request, 1);
- buf_init(&buf2, buf->len + 4);
- buf_add_uint32(&buf2, id);
- buf_add_mem(&buf2, buf->p, buf->len);
-
req->want_reply = expect_type != 0 ? 1 : 0;
req->end_func = end_func;
req->data = data;
@@ -947,7 +943,11 @@ static int sftp_request_common(uint8_t type, const struct buffer *buf,
buf_init(&req->reply, 0);
if (begin_func)
begin_func(req);
+ buf_init(&buf2, buf->len + 4);
pthread_mutex_lock(&lock);
+ id = sftp_get_id();
+ buf_add_uint32(&buf2, id);
+ buf_add_mem(&buf2, buf->p, buf->len);
err = start_processing_thread();
if (err) {
pthread_mutex_unlock(&lock);