[master] 0474080d5 Polishing VMOD JSON handling
Poul-Henning Kamp
phk at FreeBSD.org
Tue Jun 28 08:53:07 UTC 2022
commit 0474080d5bca98cc6e6e56d618d489ccf2bca143
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Tue Jun 28 08:51:58 2022 +0000
Polishing VMOD JSON handling
diff --git a/lib/libvcc/vcc_vmod.c b/lib/libvcc/vcc_vmod.c
index 0e9463e82..0fa316eef 100644
--- a/lib/libvcc/vcc_vmod.c
+++ b/lib/libvcc/vcc_vmod.c
@@ -77,7 +77,7 @@ static int
vcc_path_open(void *priv, const char *fn)
{
struct vmod_import *vim;
- const char *magic = "VMOD_JSON_SPEC\x03", *p;
+ const char *magic = "VMOD_JSON_SPEC\x02", *p;
int c;
FILE *f;
@@ -114,10 +114,10 @@ vcc_path_open(void *priv, const char *fn)
c = getc(f);
if (c == EOF) {
AZ(fclose(f));
- vim->err = "No VMOD JSON found";
+ vim->err = "Truncated VMOD JSON";
return (-1);
}
- if (c == '\0')
+ if (c == '\x03')
break;
VSB_putc(vim->json, c);
}
@@ -442,7 +442,7 @@ vcc_ParseImport(struct vcc *tl)
"Could not open VMOD %.*s\n", PF(mod));
VSB_printf(tl->sb, "\tFile name: %s\n",
vim->path != NULL ? vim->path : fn);
- VSB_printf(tl->sb, "\tdlerror: %s\n", vim->err);
+ VSB_printf(tl->sb, "\tError: %s\n", vim->err);
}
vcc_ErrWhere(tl, mod);
vcc_vim_destroy(&vim);
diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py
index 50e5ab99b..4f051282f 100755
--- a/lib/libvcc/vmodtool.py
+++ b/lib/libvcc/vmodtool.py
@@ -1105,7 +1105,7 @@ class vcc(object):
def json(self, fo, fnx):
fo.write('#define STRINGIFY(arg) #arg\n')
fo.write("\nstatic const char Vmod_Json[] = {\n")
- fo.write('\t"VMOD_JSON_SPEC\\x03"\n')
+ fo.write('\t"VMOD_JSON_SPEC\x02"\n')
for n, i in enumerate(self.iter_json(fnx)):
fo.write('\t"')
@@ -1121,7 +1121,7 @@ class vcc(object):
fo.write('\t STRINGIFY(%s)\n' % self.vrt_minor)
else:
fo.write('"\n')
- fo.write('\t\"\\n\"\n};\n')
+ fo.write('\t\"\\n\\x03\"\n};\n')
fo.write('#undef STRINGIFY\n')
More information about the varnish-commit
mailing list