Skip to contentSkip to conversation

version pointer uninitialized

PATCH In review Tomas Bortoli 3 participants 4 messages Jul 9, 2018 – Jul 12, 2018

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 version pointer uninitialized

The p9_client_version() does not initialize the version pointer. If the call to p9pdu_readf() returns an error and version has not been allocated in p9pdu_readf(), then the program will jump to the "error" label and will try to free the version pointer. If version is not initialized, free() will be called with uninitialized, garbage data and will provoke a crash.

---
 net/9p/client.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/9p/client.c +1 -1
index 18c5271910dc..40f7c47f2f74 100644
@@ -957,7 +957,7 @@ static int p9_client_version(struct p9_client *c)
 {
 	int err = 0;
 	struct p9_req_t *req;
-	char *version;
+	char *version = NULL;
 	int msize;
 
 	p9_debug(P9_DEBUG_9P, ">>> TVERSION msize %d protocol %d\n",
Signature · 1 line
2.11.0
Reviewed-by on v1 1/1
#1 lore raw

LGTM

Quoted 9 lines · Tomas Bortoli

The p9_client_version() does not initialize the version pointer. If the call to p9pdu_readf() returns an error and version has not been allocated in p9pdu_readf(), then the program will jump to the "error" label and will try to free the version pointer. If version is not initialized, free() will be called with uninitialized, garbage data and will provoke a crash.

Quoted 18 lines
---
 net/9p/client.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/9p/client.c +1 -1
index 18c5271910dc..40f7c47f2f74 100644
@@ -957,7 +957,7 @@ static int p9_client_version(struct p9_client *c)
 {
 	int err = 0;
 	struct p9_req_t *req;
-	char *version;
+	char *version = NULL;
 	int msize;
 
 	p9_debug(P9_DEBUG_9P, ">>> TVERSION msize %d protocol %d\n",
Reviewed-by on v1 1/1
#2 lore raw
In reply to Tomas Bortoli
Quoted 8 lines · Tomas Bortoli

The p9_client_version() does not initialize the version pointer. If the call to p9pdu_readf() returns an error and version has not been allocated in p9pdu_readf(), then the program will jump to the "error" label and will try to free the version pointer. If version is not initialized, free() will be called with uninitialized, garbage data and will provoke a crash.

Quoted 19 lines
Reported-by [email protected]
---
 net/9p/client.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/9p/client.c +1 -1
index 18c5271910dc..40f7c47f2f74 100644
@@ -957,7 +957,7 @@ static int p9_client_version(struct p9_client *c)
 {
 	int err = 0;
 	struct p9_req_t *req;
-	char *version;
+	char *version = NULL;
 	int msize;
 
 	p9_debug(P9_DEBUG_9P, ">>> TVERSION msize %d protocol %d\n",
#3 lore raw
Quoted 28 lines · jiangyiwen
Quoted 8 lines · Tomas Bortoli

The p9_client_version() does not initialize the version pointer. If the call to p9pdu_readf() returns an error and version has not been allocated in p9pdu_readf(), then the program will jump to the "error" label and will try to free the version pointer. If version is not initialized, free() will be called with uninitialized, garbage data and will provoke a crash.

Quoted 17 lines
Reported-by [email protected]
---
 net/9p/client.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/9p/client.c +1 -1
index 18c5271910dc..40f7c47f2f74 100644
@@ -957,7 +957,7 @@ static int p9_client_version(struct p9_client *c)
 {
 	int err = 0;
 	struct p9_req_t *req;
-	char *version;
+	char *version = NULL;
 	int msize;
 
Quoted 3 lines

net/9p/client.c static int p9_client_version(struct p9_client *c) · line 963

Quoted 2 lines
net/9p/client.c +0 -0
 	p9_debug(P9_DEBUG_9P, ">>> TVERSION msize %d protocol %d\n",

+ Cc: Andrew Morton <[email protected]>

This goes with the other patch: [V9fs-developer] [PATCH] p9_parse_header() validate PDU length

Tomas