libxl: Fix format string abuses / vulnerabilities
PATCH 1/1 libxl: Fix format string abuses / vulnerabilities
There are a few places where libxl__xs_write is passed a variable value to write to xenstore, but the semantics are that the first char* is a format string. So use "%s".
This fixes the following errors reported by some newer compilers:
libxl.c: In function "libxl_create_cpupool":
libxl.c:3981: error: format not a string literal and no format arguments libxl.c:3983: error: format not a string literal and no format arguments libxl.c: In function "libxl_cpupool_movedomain":
libxl.c:4095: error: format not a string literal and no format arguments
tools/libxl/libxl.c +8 -5
@@ -3977,10 +3977,12 @@ int libxl_create_cpupool(libxl_ctx *ctx, t =xs_transaction_start (ctx->xsh);xs_mkdir (ctx->xsh, t,libxl__sprintf (&gc,"/local/pool/%d" , *poolid)); -libxl__xs_write (&gc, t,libxl__sprintf (&gc,"/local/pool/%d/uuid" , *poolid), - uuid_string); -libxl__xs_write (&gc, t,libxl__sprintf (&gc,"/local/pool/%d/name" , *poolid), - name); +libxl__xs_write (&gc, t, +libxl__sprintf (&gc,"/local/pool/%d/uuid" , *poolid), +"%s" , uuid_string); +libxl__xs_write (&gc, t, +libxl__sprintf (&gc,"/local/pool/%d/name" , *poolid), +"%s" , name);if (xs_transaction_end (ctx->xsh, t,0 ) || (errno !=EAGAIN ))return 0 ;
@@ -4092,7 +4094,8 @@ int libxl_cpupool_movedomain(libxl_ctx *if (!vm_path)break ; -libxl__xs_write (&gc, t,libxl__sprintf (&gc,"%s/pool_name" , vm_path), poolname); +libxl__xs_write (&gc, t,libxl__sprintf (&gc,"%s/pool_name" , vm_path), +"%s" , poolname);if (xs_transaction_end (ctx->xsh, t,0 ) || (errno !=EAGAIN ))break ;
Quoted 4 lines · Ian Jackson
There are a few places where
libxl__xs_writeis passed a variable value to write to xenstore, but the semantics are that the first char* is a format string. So use "%s".
Quoted 8 lines
This fixes the following errors reported by some newer compilers:
libxl.c: In function "libxl_create_cpupool":
libxl.c:3981: error: format not a string literal and no format arguments libxl.c:3983: error: format not a string literal and no format argumentslibxl.c: In function "libxl_cpupool_movedomain":
libxl.c:4095: error: format not a string literal and no format argumentsSigned-off-by Ian Jackson <[email protected]>
Makes sense.
Quoted 36 lines
diff -r
28a160746815tools/libxl/libxl.ctools/libxl/libxl.c +8
-5@@ -3977,10 +3977,12 @@ int libxl_create_cpupool(libxl_ctx *ctx, t =xs_transaction_start (ctx->xsh);xs_mkdir (ctx->xsh, t,libxl__sprintf (&gc,"/local/pool/%d" , *poolid)); -libxl__xs_write (&gc, t,libxl__sprintf (&gc,"/local/pool/%d/uuid" , *poolid), - uuid_string); -libxl__xs_write (&gc, t,libxl__sprintf (&gc,"/local/pool/%d/name" , *poolid), - name); +libxl__xs_write (&gc, t, +libxl__sprintf (&gc,"/local/pool/%d/uuid" , *poolid), +"%s" , uuid_string); +libxl__xs_write (&gc, t, +libxl__sprintf (&gc,"/local/pool/%d/name" , *poolid), +"%s" , name);if (xs_transaction_end (ctx->xsh, t,0 ) || (errno !=EAGAIN ))return 0 ;@@ -4092,7 +4094,8 @@ int libxl_cpupool_movedomain(libxl_ctx *if (!vm_path)break ; -libxl__xs_write (&gc, t,libxl__sprintf (&gc,"%s/pool_name" , vm_path), poolname); +libxl__xs_write (&gc, t,libxl__sprintf (&gc,"%s/pool_name" , vm_path), +"%s" , poolname);if (xs_transaction_end (ctx->xsh, t,0 ) || (errno !=EAGAIN ))break ;_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 34 lines · Ian Jackson
There are a few places where
libxl__xs_writeis passed a variable value to write to xenstore, but the semantics are that the first char* is a format string. So use "%s".This fixes the following errors reported by some newer compilers:
libxl.c: In function "libxl_create_cpupool":
libxl.c:3981: error: format not a string literal and no format arguments libxl.c:3983: error: format not a string literal and no format argumentslibxl.c: In function "libxl_cpupool_movedomain":
libxl.c:4095: error: format not a string literal and no format argumentsSigned-off-by Ian Jackson <[email protected]>diff -r
28a160746815tools/libxl/libxl.ctools/libxl/libxl.c +6
-4@@ -3977,10 +3977,12 @@ int libxl_create_cpupool(libxl_ctx *ctx, t =xs_transaction_start (ctx->xsh);xs_mkdir (ctx->xsh, t,libxl__sprintf (&gc,"/local/pool/%d" , *poolid)); -libxl__xs_write (&gc, t,libxl__sprintf (&gc,"/local/pool/%d/uuid" , *poolid), - uuid_string); -libxl__xs_write (&gc, t,libxl__sprintf (&gc,"/local/pool/%d/name" , *poolid), - name); +libxl__xs_write (&gc, t, +libxl__sprintf (&gc,"/local/pool/%d/uuid" , *poolid), +"%s" , uuid_string); +libxl__xs_write (&gc, t, +libxl__sprintf (&gc,"/local/pool/%d/name" , *poolid), +"%s" , name);if (xs_transaction_end (ctx->xsh, t,0 ) || (errno !=EAGAIN ))return 0 ;
tools/libxl/libxl.c int libxl_cpupool_movedomain(libxl_ctx * · line 4099
Quoted 7 lines
tools/libxl/libxl.c +2
-1@@ -4092,7 +4094,8 @@ int libxl_cpupool_movedomain(libxl_ctx *if (!vm_path)break ; -libxl__xs_write (&gc, t,libxl__sprintf (&gc,"%s/pool_name" , vm_path), poolname); +libxl__xs_write (&gc, t,libxl__sprintf (&gc,"%s/pool_name" , vm_path), +"%s" , poolname);
Good lord!
Ack.
Gianni
Re: [PATCH] libxl: Fix format string abuses / vulnerabilities [and 2 more messages]
In reply to Ian JacksonIan Jackson writes ("[Xen-devel] [PATCH] libxl: Fix format string abuses / vulnerabilities"):
Quoted 3 lines
There are a few places where
libxl__xs_writeis passed a variable value to write to xenstore, but the semantics are that the first char* is a format string. So use "%s".
Ian Campbell writes ("Re: [Xen-devel] [PATCH] libxl: Fix format string abuses / vulnerabilities"):
Quoted 1 line
Makes sense.
Gianni Tedesco writes ("Re: [Xen-devel] [PATCH] libxl: Fix format string abuses / vulnerabilities"):
Quoted 2 lines
Good lord!
Ack.
I've applied it.
Thanks,
Ian.