52 lines
1.3 KiB
Diff
52 lines
1.3 KiB
Diff
|
Patch vampirised from Debian's packaging of keyutils-1.4
|
||
|
|
||
|
Author: Michael Gebetsroither <gebi@grml.org>
|
||
|
Description: Fixed memleak from realloc (Closes: #496466).
|
||
|
|
||
|
diff -Naurp keyutils.orig/keyutils.c keyutils/keyutils.c
|
||
|
--- keyutils.orig/keyutils.c 2008-08-09 21:46:52.000000000 +0200
|
||
|
+++ keyutils/keyutils.c 2008-08-25 13:38:07.000000000 +0200
|
||
|
@@ -165,6 +165,24 @@ long keyctl_assume_authority(key_serial_
|
||
|
return keyctl(KEYCTL_ASSUME_AUTHORITY, id);
|
||
|
}
|
||
|
|
||
|
+
|
||
|
+/*****************************************************************************/
|
||
|
+/*
|
||
|
+ * plain realloc is just crazy
|
||
|
+ */
|
||
|
+static void* __xrealloc(void* ptr, size_t size)
|
||
|
+{
|
||
|
+ void* ret;
|
||
|
+
|
||
|
+ ret = realloc(ptr, size);
|
||
|
+ if(!ret) {
|
||
|
+ free(ptr);
|
||
|
+ return 0;
|
||
|
+ }
|
||
|
+ return ret;
|
||
|
+}
|
||
|
+
|
||
|
+
|
||
|
/*****************************************************************************/
|
||
|
/*
|
||
|
* fetch key description into an allocated buffer
|
||
|
@@ -194,7 +212,7 @@ int keyctl_describe_alloc(key_serial_t i
|
||
|
break;
|
||
|
|
||
|
buflen = ret;
|
||
|
- buf = realloc(buf, buflen);
|
||
|
+ buf = __xrealloc(buf, buflen);
|
||
|
if (!buf)
|
||
|
return -1;
|
||
|
}
|
||
|
@@ -233,7 +251,7 @@ int keyctl_read_alloc(key_serial_t id, v
|
||
|
break;
|
||
|
|
||
|
buflen = ret;
|
||
|
- buf = realloc(buf, buflen + 1);
|
||
|
+ buf = __xrealloc(buf, buflen + 1);
|
||
|
if (!buf)
|
||
|
return -1;
|
||
|
}
|