[PATCH tabled 2/2] server/server.c: don't deref NULL on failed strdup

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

 



This first one is so small it barely deserved a commit.
The second fixes a bug.

>From 8e6255aa5cddd7bd58d7e4dbd2ecc81f84c51ea2 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@xxxxxxxxxx>
Date: Thu, 23 Sep 2010 10:47:22 +0200
Subject: [PATCH tabled 1/2] server/server.c: use "sizeof s" rather than equivalent "64"


Signed-off-by: Jim Meyering <meyering@xxxxxxxxxx>
---
 server/server.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/server/server.c b/server/server.c
index 3398026..a1af4f0 100644
--- a/server/server.c
+++ b/server/server.c
@@ -356,7 +356,7 @@ static int authcheck(struct http_req *req, char *extra_bucket,
 		if (rc != DB_NOTFOUND) {
 			char s[64];

-			snprintf(s, 64, "get user '%s'", user);
+			snprintf(s, sizeof s, "get user '%s'", user);
 			tdbrep.tdb.passwd->err(tdbrep.tdb.passwd, rc, s);
 		}
 	} else {
--
1.7.3.234.g7bba3


>From cf1f535adee9d93769cac5754c108ea9dac8a5c2 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@xxxxxxxxxx>
Date: Thu, 23 Sep 2010 10:56:01 +0200
Subject: [PATCH tabled 2/2] server/server.c: don't deref NULL on failed strdup

Otherwise, hreq_sign(..., ..., NULL,...) would end up
calling strlen(NULL).

Signed-off-by: Jim Meyering <meyering@xxxxxxxxxx>
---
 server/server.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/server/server.c b/server/server.c
index a1af4f0..87681a9 100644
--- a/server/server.c
+++ b/server/server.c
@@ -363,6 +363,10 @@ static int authcheck(struct http_req *req, char *extra_bucket,
 		pass = val.data;
 	}

+	if (!pass) {
+		goto err_cmp;
+	}
+
 	hreq_sign(req, extra_bucket, pass, b64sig);
 	free(pass);

--
1.7.3.234.g7bba3
--
To unsubscribe from this list: send the line "unsubscribe hail-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Fedora Clound]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux