]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tree-wide: port all calls to alloca() to alloca_safe()
authorLennart Poettering <lennart@poettering.net>
Wed, 13 Oct 2021 10:07:52 +0000 (12:07 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 14 Oct 2021 13:57:52 +0000 (15:57 +0200)
src/core/automount.c
src/journal/journalctl.c
src/libsystemd/sd-journal/journal-authenticate.c
src/libsystemd/sd-journal/journal-send.c
src/shared/firewall-util-iptables.c
src/shared/nscd-flush.c

index 11eb352b9b56b6a34fbd050fa35c2af1f618a3be..5a004f82d5225f9e6d36942d21e57b75b02b016d 100644 (file)
@@ -365,7 +365,7 @@ static int open_ioctl_fd(int dev_autofs_fd, const char *where, dev_t devid) {
         assert(where);
 
         l = sizeof(struct autofs_dev_ioctl) + strlen(where) + 1;
-        param = alloca(l);
+        param = alloca_safe(l);
 
         init_autofs_dev_ioctl(param);
         param->size = l;
index 0eb27b88b295f22cfece988ef51c54527926f7e6..daa7c7e45e19d7cbb395f47f780d66faba068630 100644 (file)
@@ -1874,13 +1874,13 @@ static int setup_keys(void) {
                 return log_oom();
 
         mpk_size = FSPRG_mskinbytes(FSPRG_RECOMMENDED_SECPAR);
-        mpk = alloca(mpk_size);
+        mpk = alloca_safe(mpk_size);
 
         seed_size = FSPRG_RECOMMENDED_SEEDLEN;
-        seed = alloca(seed_size);
+        seed = alloca_safe(seed_size);
 
         state_size = FSPRG_stateinbytes(FSPRG_RECOMMENDED_SECPAR);
-        state = alloca(state_size);
+        state = alloca_safe(state_size);
 
         log_info("Generating seed...");
         r = genuine_random_bytes(seed, seed_size, RANDOM_BLOCK);
index 0bfe9f7f477e16a0ed577f2161b201b1a0c9bf87..0ff25c1f4729bf6462e7252f93e799501427e72b 100644 (file)
@@ -182,14 +182,13 @@ int journal_file_fsprg_seek(JournalFile *f, uint64_t goal) {
         } else {
                 f->fsprg_state_size = FSPRG_stateinbytes(FSPRG_RECOMMENDED_SECPAR);
                 f->fsprg_state = malloc(f->fsprg_state_size);
-
                 if (!f->fsprg_state)
                         return -ENOMEM;
         }
 
         log_debug("Seeking FSPRG key to %"PRIu64".", goal);
 
-        msk = alloca(FSPRG_mskinbytes(FSPRG_RECOMMENDED_SECPAR));
+        msk = alloca_safe(FSPRG_mskinbytes(FSPRG_RECOMMENDED_SECPAR));
         FSPRG_GenMK(msk, NULL, f->fsprg_seed, f->fsprg_seed_size, FSPRG_RECOMMENDED_SECPAR);
         FSPRG_Seek(f->fsprg_state, goal, msk, f->fsprg_seed, f->fsprg_seed_size);
         return 0;
index fd3fd7ef9c944060cb565f7454e832181ccd4282..421782515631793cb6d1d0c61783b287bb24395d 100644 (file)
@@ -96,7 +96,7 @@ _public_ int sd_journal_printv(int priority, const char *format, va_list ap) {
 
         /* Allocate large buffer to accommodate big message */
         if (len >= LINE_MAX) {
-                buffer = alloca(len + 9);
+                buffer = alloca_safe(len + 9);
                 memcpy(buffer, "MESSAGE=", 8);
                 assert_se(vsnprintf(buffer + 8, len + 1, format, ap) == len);
         }
@@ -472,7 +472,7 @@ _public_ int sd_journal_printv_with_location(int priority, const char *file, con
 
         /* Allocate large buffer to accommodate big message */
         if (len >= LINE_MAX) {
-                buffer = alloca(len + 9);
+                buffer = alloca_safe(len + 9);
                 memcpy(buffer, "MESSAGE=", 8);
                 assert_se(vsnprintf(buffer + 8, len + 1, format, ap) == len);
         }
index d53a394895aae835f1334fe137ed2e67619aace9..55bb427e7bfb13e7f4abdbf6c1bcaf1a9d0af13f 100644 (file)
@@ -128,7 +128,7 @@ int fw_iptables_add_masquerade(
         mr->rangesize = 1;
 
         /* Create a search mask entry */
-        mask = alloca(sz);
+        mask = alloca_safe(sz);
         memset(mask, 0xFF, sz);
 
         if (add) {
index 19e16d93455c88662e040e97d19f10ef014e335d..06550306338581ebd7f312b342c3669351f572d2 100644 (file)
@@ -35,7 +35,7 @@ static int nscd_flush_cache_one(const char *database, usec_t end) {
         l = strlen(database);
         req_size = offsetof(struct nscdInvalidateRequest, dbname) + l + 1;
 
-        req = alloca(req_size);
+        req = alloca_safe(req_size);
         *req = (struct nscdInvalidateRequest) {
                 .version = 2,
                 .type = 10,