The following commit has been merged in the master branch:
commit 173a6cb53258403f339ae090507cbb100b742604
Author: Guillem Jover <[email protected]>
Date:   Sat Feb 19 06:12:15 2011 +0100

    libdpkg: Do not add a NUL char after varbuf_printf() calls
    
    The varbuf_printf() and varbuf_vprintf() already NUL terminate the
    string via the vsnprintf() calls. No need to do that again.

diff --git a/lib/dpkg/log.c b/lib/dpkg/log.c
index 0819cb3..b8e5e9f 100644
--- a/lib/dpkg/log.c
+++ b/lib/dpkg/log.c
@@ -62,7 +62,6 @@ log_message(const char *fmt, ...)
        va_start(args, fmt);
        varbuf_reset(&log);
        varbuf_vprintf(&log, fmt, args);
-       varbuf_add_char(&log, '\0');
        va_end(args);
 
        time(&now);
diff --git a/lib/dpkg/test/t-varbuf.c b/lib/dpkg/test/t-varbuf.c
index 5a44071..6602446 100644
--- a/lib/dpkg/test/t-varbuf.c
+++ b/lib/dpkg/test/t-varbuf.c
@@ -2,7 +2,7 @@
  * libdpkg - Debian packaging suite library routines
  * t-verbuf.c - test varbuf implementation
  *
- * Copyright © 2009 Guillem Jover <[email protected]>
+ * Copyright © 2009-2011 Guillem Jover <[email protected]>
  *
  * This is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -24,6 +24,7 @@
 #include <dpkg/test.h>
 #include <dpkg/varbuf.h>
 
+#include <string.h>
 #include <stdlib.h>
 
 static void
@@ -207,8 +208,7 @@ test_varbuf_printf(void)
 
        /* Test normal format printing. */
        varbuf_printf(&vb, "format %s number %d", "string", 10);
-       varbuf_add_char(&vb, '\0');
-       test_pass(vb.used == sizeof("format string number 10"));
+       test_pass(vb.used == strlen("format string number 10"));
        test_pass(vb.size >= vb.used);
        test_str(vb.buf, ==, "format string number 10");
 
@@ -217,8 +217,7 @@ test_varbuf_printf(void)
        /* Test concatenated format printing. */
        varbuf_printf(&vb, "format %s number %d", "string", 10);
        varbuf_printf(&vb, " extra %s", "string");
-       varbuf_add_char(&vb, '\0');
-       test_pass(vb.used == sizeof("format string number 10 extra string"));
+       test_pass(vb.used == strlen("format string number 10 extra string"));
        test_pass(vb.size >= vb.used);
        test_str(vb.buf, ==, "format string number 10 extra string");
 
diff --git a/lib/dpkg/triglib.c b/lib/dpkg/triglib.c
index 52636a0..84ce92e 100644
--- a/lib/dpkg/triglib.c
+++ b/lib/dpkg/triglib.c
@@ -423,7 +423,6 @@ trk_explicit_interest_change(const char *trig,  struct 
pkginfo *pkg, int signum)
        trk_explicit_start(trig);
        varbuf_reset(&newfn);
        varbuf_printf(&newfn, "%s/%s.new", triggersdir, trig);
-       varbuf_add_char(&newfn, '\0');
 
        nf = fopen(newfn.buf, "w");
        if (!nf)

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]

Reply via email to