* tests/print_quoted_string.c (print_quoted_memory): New function.
(print_quoted_string): Use it.
* tests/tests.h (print_quoted_memory): New prototype.
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
/*
* Based on string_quote() from util.c.
void
print_quoted_string(const char *instr)
+{
+ print_quoted_memory(instr, strlen(instr));
+}
+
+void
+print_quoted_memory(const char *instr, const size_t len)
{
const unsigned char *str = (const unsigned char*) instr;
- int c;
+ size_t i;
- while ((c = *(str++))) {
+ for (i = 0; i < len; ++i) {
+ const int c = str[i];
switch (c) {
case '\"':
printf("\\\"");
/* Return inode number of socket descriptor. */
unsigned long inode_of_sockfd(int);
-/* Print string in quoted form. */
+/* Print string in a quoted form. */
void print_quoted_string(const char *);
+/* Print memory in a quoted form. */
+void print_quoted_memory(const char *, size_t);
+
/* Check whether given uid matches kernel overflowuid. */
void check_overflowuid(const int);