commit:     b2f5531194e33c229462e9f52fa1d9388463f7b7
Author:     William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Wed Jun 20 22:45:01 2018 +0000
Commit:     William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Wed Jun 20 22:45:01 2018 +0000
URL:        https://gitweb.gentoo.org/proj/openrc.git/commit/?id=b2f55311

librc-misc: convert snprintf calls to xasprintf

 src/librc/librc-misc.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/src/librc/librc-misc.c b/src/librc/librc-misc.c
index 9d514bcd..178768c5 100644
--- a/src/librc/librc-misc.c
+++ b/src/librc/librc-misc.c
@@ -237,13 +237,9 @@ static void rc_config_set_value(RC_STRINGLIST *config, 
char *value)
                if (token[i] == '\n')
                        token[i] = 0;
 
-               i = strlen(entry) + strlen(token) + 2;
-               newline = xmalloc(sizeof(char) * i);
-               snprintf(newline, i, "%s=%s", entry, token);
+               xasprintf(&newline, "%s=%s", entry, token);
        } else {
-               i = strlen(entry) + 2;
-               newline = xmalloc(sizeof(char) * i);
-               snprintf(newline, i, "%s=", entry);
+               xasprintf(&newline, "%s=", entry);
        }
 
        replaced = false;
@@ -300,8 +296,7 @@ static RC_STRINGLIST *rc_config_kcl(RC_STRINGLIST *config)
 
                if (value != NULL) {
                        len = varlen + strlen(value) + 2;
-                       tmp = xmalloc(sizeof(char) * len);
-                       snprintf(tmp, len, "%s=%s", override->value, value);
+                       xasprintf(&tmp, "%s=%s", override->value, value);
                }
 
                /*

Reply via email to