]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
escape: use snprintf
authorSage Weil <sage.weil@dreamhost.com>
Sun, 21 Aug 2011 21:10:41 +0000 (14:10 -0700)
committerSage Weil <sage.weil@dreamhost.com>
Sun, 21 Aug 2011 21:10:41 +0000 (14:10 -0700)
Coverity cid 41, 40

Signed-off-by: Sage Weil <sage.weil@dreamhost.com>
src/common/escape.c

index 3249df11b97f3b4ae3253ef9488db4e3c460117c..f46f2bdd0f78e4bdddb157e57b04622134a81b81 100644 (file)
@@ -99,7 +99,7 @@ void escape_xml_attr(const char *buf, char *out)
                        // Escape control characters.
                        if (((c < 0x20) && (c != 0x09) && (c != 0x0a)) ||
                                    (c == 0x7f)) {
-                               sprintf(o, "&#x%02x;", c);
+                               snprintf(o, 6, "&#x%02x;", c);
                                o += 6;
                        }
                        else {
@@ -185,7 +185,7 @@ void escape_json_attr(const char *buf, char *out)
                default:
                        // Escape control characters.
                        if ((c < 0x20) || (c == 0x7f)) {
-                               sprintf(o, "\\%04x", c);
+                               snprintf(o, 5, "\\%04x", c);
                                o += 5;
                        }
                        else {