diff mbox

[5/5] libsepol: fix unknown magic section number error message

Message ID 20161122222342.16771-5-nicolas.iooss@m4x.org (mailing list archive)
State Not Applicable
Headers show

Commit Message

Nicolas Iooss Nov. 22, 2016, 10:23 p.m. UTC
When running hll/pp on some invalid policy module, it can output:

    libsepol.sepol_module_package_read: unknown magic number at section
    1, offset: 251, number: 0x

The last number looks funny and was caused by using "%ux". "u" is not a
prefix like "l", "h", "z"... and "%x" already expects an unsigned
integer (cf. http://man7.org/linux/man-pages/man3/printf.3.html).

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
---
 libsepol/src/module.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Stephen Smalley Nov. 23, 2016, 5:35 p.m. UTC | #1
On 11/22/2016 05:23 PM, Nicolas Iooss wrote:
> When running hll/pp on some invalid policy module, it can output:
> 
>     libsepol.sepol_module_package_read: unknown magic number at section
>     1, offset: 251, number: 0x
> 
> The last number looks funny and was caused by using "%ux". "u" is not a
> prefix like "l", "h", "z"... and "%x" already expects an unsigned
> integer (cf. http://man7.org/linux/man-pages/man3/printf.3.html).
> 
> Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>

Thanks, applied all five patches.

> ---
>  libsepol/src/module.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libsepol/src/module.c b/libsepol/src/module.c
> index 1c2becea5ef6..219355f30d27 100644
> --- a/libsepol/src/module.c
> +++ b/libsepol/src/module.c
> @@ -627,7 +627,7 @@ int sepol_module_package_read(sepol_module_package_t * mod,
>  		default:
>  			/* unknown section, ignore */
>  			ERR(file->handle,
> -			    "unknown magic number at section %u, offset: %zx, number: %ux ",
> +			    "unknown magic number at section %u, offset: %zx, number: %x ",
>  			    i, offsets[i], le32_to_cpu(buf[0]));
>  			break;
>  		}
>
diff mbox

Patch

diff --git a/libsepol/src/module.c b/libsepol/src/module.c
index 1c2becea5ef6..219355f30d27 100644
--- a/libsepol/src/module.c
+++ b/libsepol/src/module.c
@@ -627,7 +627,7 @@  int sepol_module_package_read(sepol_module_package_t * mod,
 		default:
 			/* unknown section, ignore */
 			ERR(file->handle,
-			    "unknown magic number at section %u, offset: %zx, number: %ux ",
+			    "unknown magic number at section %u, offset: %zx, number: %x ",
 			    i, offsets[i], le32_to_cpu(buf[0]));
 			break;
 		}