2100 Commits

Author SHA1 Message Date
Alexander Amelkin
61bb233c5b Fix compiler warning
Move #ifdef from the inside to the outside of assert()'s
to get rid of this compiler warning:

warning: embedding a directive within macro arguments has undefined
behavior [-Wembedded-directive]

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2021-04-21 13:24:43 +03:00
Alexander Amelkin
fb176a1995 Fix compiler warning
Drop some unused variables detected by the compiler

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2021-04-21 13:24:43 +03:00
Alexander Amelkin
d88bbf3c41 Fix compiler warning
Refactor plugin ipmi_intf structure initialization for some
plugins to stop the compiler complaining like this:

warning: use of GNU old-style field designator
extension [-Wgnu-designator]

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2021-04-21 13:24:43 +03:00
Bing-Hua Wang
69cdef116a ci: Update for GitHub Actions v2.274.2
set-env and add-path have been removed since GitHub Actions v2.274.2. [1]
Switch to Environment Files instead. [2]

[1] https://github.blog/changelog/2020-11-09-github-actions-removing-set-env-and-add-path-commands-on-november-16/
[2] https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#environment-files
2021-04-08 11:29:25 +03:00
Bing-Hua Wang
9a86189425 free: Fix implicit function declarations
GitHub Actions macOS environment now has Xcode 12.0.1. [1]
Xcode 12 Clang enables -Werror=implicit-function-declaration by
default [2] and breaks the ipmitool build on macOS. [3]

[1] https://github.com/actions/virtual-environments/issues/1712
[2] https://developer.apple.com/documentation/xcode-release-notes/xcode-12-release-notes
    "Clang now reports an error when you use a function without an
    explicit declaration when building C or Objective-C code for macOS
    (-Werror=implicit-function-declaration flag is on)."
[3] https://github.com/ipmitool/ipmitool/pull/252/checks?check_run_id=1389463134
    "checking for ld used by gcc... /Applications/Xcode_12.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld
    <snip>
    free.c:66:13: error: implicit declaration of function 'getuid' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
            if (getuid() != 0) {
                ^
    free.c:170:26: error: implicit declaration of function 'ipmi_get_oem' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
            intf->manufacturer_id = ipmi_get_oem(intf);"
                                ^

Signed-off-by: Bing-Hua Wang <binghuawang@ami.com>
2021-04-08 11:29:25 +03:00
Bing-Hua Wang
5a36080f92 Use "#pragma once" for headers
Some of the header guard names in ipmitool duplicated with the ones in
freeipmi.

* ipmitool/ipmi_fru.h and freeipmi/fru/ipmi-fru.h both uses IPMI_FRU_H
* ipmitool/ipmi_sdr.h and freeipmi/sdr/ipmi-sdr.h both uses IPMI_SDR_H
* ipmitool/ipmi_sel.h and freeipmi/sel/ipmi-sel.h both uses IPMI_SEL_H

This is problematic as including the 1st will prevent the 2nd from being
included, leading to the loss of any declarations, inline definitions,
or other "#includes" in the 2nd header.

For example, including ipmitool/ipmi_sel.h and freeipmi/freeipmi.h fails
to build.

$ cat test.c
 #include <ipmitool/ipmi_sel.h>
 #include <freeipmi/freeipmi.h>
$ gcc test.c -I${HOME}/src/oss/ipmitool/include
In file included from /usr/include/freeipmi/freeipmi.h:90,
                 from test.c:2:
/usr/include/freeipmi/sdr/oem/ipmi-sdr-oem-intel-node-manager.h:48:44: error: unknown type name 'ipmi_sdr_ctx_t'; did you mean 'ipmi_fru_ctx_t'?
   48 | int ipmi_sdr_oem_parse_intel_node_manager (ipmi_sdr_ctx_t ctx,
      |                                            ^~~~~~~~~~~~~~
      |                                            ipmi_fru_ctx_t

Remove header guards and use "#pragma once" instead. In this way, we
don't have to do manual management to avoid name clashes.
* src/plugins/lan/md5.h is left as is being an external header
  originally.
* src/plugins/imb/imbapi.h is a convoluted header consisting of multiple
  header guards. Let's just add "#pragma once" and leave header guards
  as is for now.

Signed-off-by: Bing-Hua Wang <binghuawang@ami.com>
2021-04-08 11:29:25 +03:00
Bing-Hua Wang
682fec09ef Remove unneeded execution bits from C source files and a header file
Signed-off-by: Bing-Hua Wang <binghuawang@ami.com>
2021-04-08 11:29:25 +03:00
Bing-Hua Wang
e7550f722c Convert line endings to LF
The following commands is used on Linux to convert line endings to LF.

git config core.autocrlf input
git add --renormalize .
git config --unset core.autocrlf

It turns out there was only ipmi_kontronoem.h not using LF.

Signed-off-by: Bing-Hua Wang <binghuawang@ami.com>
2021-04-08 11:29:25 +03:00
Shitalkumar Gandhi
d674bfdc9a Fixed compiler warning.
This patch has been added to fix "error: comparison between signed
and unsigned integer expressions [-Werror=sign-compare]"

Signed-off-by: Shitalkumar Gandhi <shitalkumar.gandhi@seagate.com>
2021-02-24 14:10:42 +03:00
Gilles Buloz
050f5da631 RPM support: fixed broken build due to use of headers from kernel
When building an RPM, --with-kerneldir is passed to ./configure. This adds
the include path /lib/modules/<kversion>/build/include that may break the
build but is not present when building with "make" so useless.
For instance while building ipmi_sel.c with kernel 5.3.7-301.fc31.x86_64 :
/lib/modules/5.3.7-301.fc31.x86_64/build/include/linux/stddef.h:11:2: error:
expected identifier before numeric constant
   11 |  false = 0,
      |  ^~~~~

Signed-off-by: Gilles Buloz <gilles.buloz@kontron.com>
2020-10-22 18:00:36 +03:00
Heiko Thiery
7fd7c0f2ba imbapi: replace __FUNCTION__ to eleminate compiler warnings
imbapi.c:1393:52: warning: ISO C does not support ‘__FUNCTION__’ predefined identifier [-Wpedantic]
  lprintf(LOG_DEBUG, "%s: munmap(0x%x,%d) success", __FUNCTION__,

Signed-off-by: Heiko Thiery <heiko.thiery@gmail.com>
2020-10-04 22:12:47 +03:00
Heiko Thiery
e78144d2c7 lanplus: remove unused variable
Signed-off-by: Heiko Thiery <heiko.thiery@gmail.com>
2020-10-04 22:12:47 +03:00
Alexander Amelkin
7108884793 hpmfwupg: Clean up / refactor
- Drop a useless `extern` definition
- Remove static variable `errorCount` from header, move it to
  the c file where it is actually used if needed

Related to ipmitool/ipmitool#220

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2020-10-01 20:27:31 +03:00
Alexander Amelkin
1245aaa387 fru: Fix crashes on 6-bit ASCII strings
Fix calculation of the buffer size for decoded 6-bit ASCII
strings. Previously the program could allocate too a short buffer
that caused buffer overflows and segmentation fault crashes on
certain FRU contents.

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2020-09-16 13:26:53 +03:00
Alexander Amelkin
50d8c36edf Refix 6e037d6bfbbb93b349c8ca331ebde03a837f76bf
Restore using strncmp() for "options=" and similar
substrings.

Resolves ipmitool/ipmitool#223

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2020-08-07 10:53:06 +03:00
Alexander Amelkin
aee377bead
oem: Add product ID for YADRO VEGMAN
Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2020-07-23 13:41:11 +03:00
Ypnose
b302d8202c configure.ac: add '--location' for curl to follow location 2020-07-21 22:40:04 +03:00
Ypnose
3452cf1ca2 configure.ac: replace '-#' by '--progress-bar' with curl 2020-07-21 22:40:04 +03:00
Alexander Amelkin
f3ffa616e6
log: refix 16f937a1: Add missing header changes
Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2020-07-21 17:35:11 +03:00
Alexander Amelkin
16f937a117 Add version info to debug output
- Initialize the log at the start of ipmi_main() to allow for proper
  logging at the start;
- Remove the unused log_level_get() function;
- Update log_level_set() to take verbosity instead of log level
  (default verbosity is 0, which is LOG_NOTICE log level),
  use the function to update log level as `-v` is encountered
  in command line;
- Move IANA PEN list debugging to verbosity 6. The list is too long
  to see it in each debug output of verbosity 5 that is used for
  debugging lan/lanplus packets;
- For verbosity >= 2 (that is `-vv`) add the ipmitool version
  information at the start.

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2020-07-17 15:57:06 +03:00
Alexander Amelkin
3a1a9cb283 doc, ci: Fix an error in package name for Windows
it's dos2unix, not unix2dos

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2020-07-16 19:26:46 +03:00
Alexander Amelkin
239ef6a4ef
doc: Fix a small typo in INSTALL
Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2020-07-06 12:55:00 +03:00
Gilles Buloz
c6a0baee84 RPM support: updated spec file changelog
Updated specfile changelog according to the Changelog file

Signed-off-by: Gilles Buloz <gilles.buloz@kontron.com>
2020-07-04 01:48:50 +03:00
Gilles Buloz
bc13db6304 RPM support: simplified build process
Simplified target "rpm" of Makefile, and removed rpmrc and rpmmacros to use
default settings and those from the spec file such as Distribution that has
been changed to "GitHub Build" instead of "Sourceforge Build".

Signed-off-by: Gilles Buloz <gilles.buloz@kontron.com>
2020-07-04 01:48:50 +03:00
Gilles Buloz
8838e4b0e2 RPM support: fixed broken RPM build
The command "make rpm" was failing for the following reasons :
- setting the build directory to ./rpmbuild/ instead of default
  ~/rpmbuild/ was ignored.
- errors in the spec file : wrong dates and characters in the
  changelog, and unpackaged files under misc/*
- debug package built even if unneeded but failing to build because
  of missing requisites.
Using "rpmbuild -tb ipmitool-*.tar.gz" instead of 'make rpm" builds
under ~/rpmbuild/ but also fails because of the last two reasons.

Signed-off-by: Gilles Buloz <gilles.buloz@kontron.com>
2020-07-04 01:48:50 +03:00
Alexander Amelkin
055719b7b9 doc: Update INSTALL with Windows info
The documentation now contains instructions on how to build on
Windows. The instructions have been verified and added to
a continous integration workflow with the previous commit,
so Windows buildability will from now on be automatically verified.

Resolves: ipmitool/ipmitool#148 (ipmitool for win with FreeIPMI)
          ipmitool/ipmitool#200 (windows build error)
          ipmitool/ipmitool#201 (windows build error)
          ipmitool/ipmitool#203 (no lanplus on windows)

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2020-07-04 00:26:38 +03:00
Alexander Amelkin
38b120eb5a ci: Add Windows/cygwin config
Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2020-07-04 00:26:38 +03:00
Alexander Amelkin
01b53a013b doc: Update INSTALL for new CI
Update according to the new GitHub CI build configuration.
Add information regarding prerequisites for macOS X 10.15.

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2020-07-04 00:26:38 +03:00
Alexander Amelkin
0cd847579f ci: Add github workflow, drop travis
Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2020-07-04 00:26:38 +03:00
Alexander Amelkin
2158e6ea49 Fix compatibility with OpenBSD and macOS
Neither of these systems have the `-t` option for `install`.
For Linux the option is not necessary and is only needed
if the target directory is specified before the source file(s).

Also, macOS produces strange files with -e suffix for man
pages when they are processed with sed using AC_CONFIG_FILES().
Move prefix expansion to another point in code to avoid these
unneeded intermediate files produced by configure.

Resolves: ipmitool/ipmitool#206
Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2020-07-04 00:26:38 +03:00
Alexander Amelkin
1f92c9ee23
dist: Fix dependencies and cleanup
The `make distcheck` was failing because of some files deleted twice
and some intermediate files not deleted at all.

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2020-06-30 16:19:35 +03:00
Alexander Amelkin
b18619e14e
dist: Add missing ipmi_time.h header to packaging
Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2020-06-30 15:51:31 +03:00
Alexander Amelkin
84469a9c54 configure: Fix compatibility with non-bash systems
Remove a bashims from configure to make build compatible
with systems without bash.

Resolves ipmitool/ipmitool#205

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2020-06-16 12:37:49 +03:00
Alexander Amelkin
956ae2b372 Finalize refactoring of string comparisons
Unify the comparison idioms use.
Always use `if(!strcmp())` for "if string equals"
and `if(strcmp())` for "if string is not equal".
Never use `== 0` and `!= 0` with `strcmp()`.

Minor reformatting of the code immediately surrounding the
refactored lines.

Resolves ipmitool/ipmitool#104

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2020-06-10 13:46:57 +03:00
Alexander Amelkin
e3fc775d26 channel: Refactor set_user_access option processing
Reduce code duplication by extracting option names, types,
and value ranges into a separate structure, and rewriting
the option parsing code without mixing it with the data.

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2020-06-10 13:46:57 +03:00
Jiang Junyu
6e037d6bfb Refactor string comparisons
Clean up use of strcmp/strncmp/strncasecmp for command line arguments.
Never use anything but `strcmp()` unless absolutely neccessary.

Partialy resolves ipmitool/ipmitool#104
2020-06-10 13:46:57 +03:00
Alexander Amelkin
9d5ea21df7
sel: Fix OEM record definition example
The example contained nested double quotes. Changed them to
single quotes.

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2020-06-05 21:12:40 +03:00
John Levon
dfe17311d6
sdr: harden against bad records
Harden ipmi_sdr_get_record() against bad records

Signed-off-by: John Levon <john.levon@joyent.com>
2020-05-26 18:03:39 +03:00
Vaclav Dolezal
b97a110721 fru: fix memory leak in ipmi_spd_print_fru
Fixed by using centralised exiting.

Signed-off-by: Václav Doležal <vdolezal@redhat.com>
2020-05-25 18:50:16 +03:00
Pavel Kiryukhin
284adfe2e2 ipmi_sel_set_time: fix strptime() return check
The current behavior:
- correct date format is not accepted by "sel time set".
- incorrect date format that looks correct is accepted, but time is not
  set correctly.
- commands like
    ipmitool sel time set "11/22/2013 trash"
  are accepted.
2020-05-22 19:47:10 +03:00
John Levon
2a17967159
hpm: use portable __max() in hpmfwupg
Instead of non-portable MAX() use __max() in hpmfwupg
2020-05-18 09:04:24 +03:00
Vaclav Dolezal
c3939dac2c hpmfwupg: move variable definition to .c file
Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
2020-02-13 13:02:48 +03:00
Pavel Kiryukhin
f80effb1fc sel: time: fix null pointer dereference in set
This is a refix of commit f0d5c17e
2020-02-12 16:37:02 +03:00
Chrostoper Ertl
7ccea283dd
fru, sdr: Fix id_string buffer overflows
Final part of the fixes for CVE-2020-5208, see
https://github.com/ipmitool/ipmitool/security/advisories/GHSA-g659-9qxw-p7cp

9 variants of stack buffer overflow when parsing `id_string` field of
SDR records returned from `CMD_GET_SDR` command.

SDR record structs have an `id_code` field, and an `id_string` `char`
array.

The length of `id_string` is calculated as `(id_code & 0x1f) + 1`,
which can be larger than expected 16 characters (if `id_code = 0xff`,
then length will be `(0xff & 0x1f) + 1 = 32`).

In numerous places, this can cause stack buffer overflow when copying
into fixed buffer of size `17` bytes from this calculated length.
2020-02-04 15:00:14 +03:00
Chrostoper Ertl
d45572d71e
lanp: Fix buffer overflows in get_lan_param_select
Partial fix for CVE-2020-5208, see
https://github.com/ipmitool/ipmitool/security/advisories/GHSA-g659-9qxw-p7cp

The `get_lan_param_select` function is missing a validation check on the
response’s `data_len`, which it then returns to caller functions, where
stack buffer overflow can occur.
2020-02-04 14:59:55 +03:00
Chrostoper Ertl
9452be8718
channel: Fix buffer overflow
Partial fix for CVE-2020-5208, see
https://github.com/ipmitool/ipmitool/security/advisories/GHSA-g659-9qxw-p7cp

The `ipmi_get_channel_cipher_suites` function does not properly check
the final response’s `data_len`, which can lead to stack buffer overflow
on the final copy.
2020-02-04 14:59:52 +03:00
Chrostoper Ertl
41d7026946
session: Fix buffer overflow in ipmi_get_session_info
Partial fix for CVE-2020-5208, see
https://github.com/ipmitool/ipmitool/security/advisories/GHSA-g659-9qxw-p7cp

The `ipmi_get_session_info` function does not properly check the
response `data_len`, which is used as a copy size, allowing stack buffer
overflow.
2020-02-04 14:59:49 +03:00
Chrostoper Ertl
840fb1cbb4
fru: Fix buffer overflow in ipmi_spd_print_fru
Partial fix for CVE-2020-5208, see
https://github.com/ipmitool/ipmitool/security/advisories/GHSA-g659-9qxw-p7cp

The `ipmi_spd_print_fru` function has a similar issue as the one fixed
by the previous commit in `read_fru_area_section`. An initial request is
made to get the `fru.size`, which is used as the size for the allocation
of `spd_data`. Inside a loop, further requests are performed to get the
copy sizes which are not checked before being used as the size for a
copy into the buffer.
2020-02-04 14:59:43 +03:00
Chrostoper Ertl
e824c23316
fru: Fix buffer overflow vulnerabilities
Partial fix for CVE-2020-5208, see
https://github.com/ipmitool/ipmitool/security/advisories/GHSA-g659-9qxw-p7cp

The `read_fru_area_section` function only performs size validation of
requested read size, and falsely assumes that the IPMI message will not
respond with more than the requested amount of data; it uses the
unvalidated response size to copy into `frubuf`. If the response is
larger than the request, this can result in overflowing the buffer.

The same issue affects the `read_fru_area` function.
2020-02-04 14:58:06 +03:00
Ivan Mikhaylov
7a66d8725d
chassis: bootmbox: Refix 62a04390
Fix ipmitool not writing the last block of boot mailbox data if the
block is shorter than 3 bytes.

Signed-off-by: Ivan Mikhaylov <fr0st61te@gmail.com>
Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
2020-01-23 18:06:47 +03:00