|
From: Kouhei S. <nul...@cl...> - 2014-01-20 08:31:51
|
Kouhei Sutou 2014-01-20 17:31:29 +0900 (Mon, 20 Jan 2014) New Revision: b451c52b59eac2e49334586018422618bf7b92d6 https://github.com/clear-code/cutter/commit/b451c52b59eac2e49334586018422618bf7b92d6 Message: Suppress a warning from GCC 4.8.1 on Ubuntu 13.10 cut-elf-loader.c: In function 'cut_elf_loader_is_elf': cut-elf-loader.c:191:37: warning: 'ident[3]' may be used uninitialized in this function [-Wmaybe-uninitialized] (ident[EI_MAG2] == ELFMAG2) && ^ cut-elf-loader.c:190:37: warning: 'ident[2]' may be used uninitialized in this function [-Wmaybe-uninitialized] (ident[EI_MAG1] == ELFMAG1) && ^ cut-elf-loader.c:189:37: warning: 'ident[1]' may be used uninitialized in this function [-Wmaybe-uninitialized] if ((ident[EI_MAG0] == ELFMAG0) && ^ cut-elf-loader.c:189:8: warning: 'ident[0]' may be used uninitialized in this function [-Wmaybe-uninitialized] if ((ident[EI_MAG0] == ELFMAG0) && GitHub: fix #9 Reported by Kazuhiro Yamato. Thanks!!! Modified files: cutter/cut-elf-loader.c Modified: cutter/cut-elf-loader.c (+10 -3) =================================================================== --- cutter/cut-elf-loader.c 2014-01-20 00:19:41 +0900 (2bb3f38) +++ cutter/cut-elf-loader.c 2014-01-20 17:31:29 +0900 (6a34213) @@ -1,6 +1,6 @@ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* - * Copyright (C) 2009-2013 Kouhei Sutou <ko...@co...> + * Copyright (C) 2009-2014 Kouhei Sutou <ko...@cl...> * * This library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -182,8 +182,15 @@ cut_elf_loader_is_elf (CutELFLoader *loader) return FALSE; } - if (priv->length >= sizeof(ident)) - memcpy(ident, priv->content, sizeof(ident)); + if (priv->length < sizeof(ident)) { + cut_log_warning("ELF file must have at least %zd size: %" G_GSIZE_FORMAT, + sizeof(ident), priv->length); + g_free(priv->content); + priv->content = NULL; + return FALSE; + } + + memcpy(ident, priv->content, sizeof(ident)); if ((ident[EI_MAG0] == ELFMAG0) && (ident[EI_MAG1] == ELFMAG1) && |