From 0ace62cb6a45b2cd710220a82a9b197c9e30b4f9 Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Tue, 18 Feb 2014 13:23:27 -0800 Subject: outelf: Error out on "section align" without value If someone specifies "section align" without =value, error out. Reported-by: Ilya Albrekht Signed-off-by: H. Peter Anvin --- output/outelf.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/output/outelf.c b/output/outelf.c index bfbf625..61ae1fc 100644 --- a/output/outelf.c +++ b/output/outelf.c @@ -1,6 +1,6 @@ /* ----------------------------------------------------------------------- * * - * Copyright 1996-2010 The NASM Authors - All Rights Reserved + * Copyright 1996-2014 The NASM Authors - All Rights Reserved * See the file AUTHORS included with the NASM distribution for * the specific copyright holders. * @@ -76,15 +76,20 @@ void section_attrib(char *name, char *attr, int pass, return; while ((opt = nasm_opt_val(opt, &val, &next))) { - if (!nasm_stricmp(opt, "align") && val) { - *align = atoi(val); - if (*align == 0) { - *align = SHA_ANY; - } else if (!is_power2(*align)) { + if (!nasm_stricmp(opt, "align")) { + if (!val) { nasm_error(ERR_NONFATAL, - "section alignment %"PRId64" is not a power of two", - *align); - *align = SHA_ANY; + "section align without value specified"); + } else { + *align = atoi(val); + if (*align == 0) { + *align = SHA_ANY; + } else if (!is_power2(*align)) { + nasm_error(ERR_NONFATAL, + "section alignment %"PRId64" is not a power of two", + *align); + *align = SHA_ANY; + } } } else if (!nasm_stricmp(opt, "alloc")) { *flags_and |= SHF_ALLOC; -- cgit v1.2.3