]> git.ipfire.org Git - thirdparty/openldap.git/commitdiff
ITS#9160 OOM handling in mdb tools
authorOndřej Kuzník <ondra@mistotebe.net>
Thu, 30 Jan 2020 08:59:57 +0000 (08:59 +0000)
committerOndřej Kuzník <ondra@mistotebe.net>
Fri, 7 Feb 2020 09:46:52 +0000 (09:46 +0000)
libraries/liblmdb/mdb_dump.c
libraries/liblmdb/mdb_stat.c

index ee7dbe85d8f29ba02e5fedb28740808af21333a2..63b08d658d5654365cfb88fbfd4993fc3fea7929 100644 (file)
@@ -279,6 +279,10 @@ int main(int argc, char *argv[])
                                continue;
                        count++;
                        str = malloc(key.mv_size+1);
+                       if (!str) {
+                               fprintf(stderr, "malloc failed\n");
+                               goto txn_abort;
+                       }
                        memcpy(str, key.mv_data, key.mv_size);
                        str[key.mv_size] = '\0';
                        rc = mdb_open(txn, str, 0, &db2);
index cb73e11322f68280048805bc1df2614bd3e552e5..f64475efe6ba4d0b01beaf08899d0eab1cd5c8e2 100644 (file)
@@ -232,6 +232,10 @@ int main(int argc, char *argv[])
                        if (memchr(key.mv_data, '\0', key.mv_size))
                                continue;
                        str = malloc(key.mv_size+1);
+                       if (!str) {
+                               fprintf(stderr, "malloc failed\n");
+                               goto txn_abort;
+                       }
                        memcpy(str, key.mv_data, key.mv_size);
                        str[key.mv_size] = '\0';
                        rc = mdb_open(txn, str, 0, &db2);