acrn-hypervisor/tools/acrn-crashlog/usercrash/include/packet.h
xiaojin2 cb39badf82 tools: acrn-crashlog: fix potential issues under common and usercrash
This patch is to fix buffer overflow, return value not unified and
variable type not matched issues. And add some judge logic to improve
code quality.

Changes:
1. Handle the fd properly in the failing case.
2. Fix buffer overflow issues and null pointer access issues.
3. Fix the format issue in log_sys.c.
4. Remove the useless branch and adjust the function logic.
5. Add some checks for the string length before using strcpy/strcat/memcpy.
6. Fix strncpy null-terminated issues.
7. Change the return value to unify the return type.

Signed-off-by: CHEN Gang <gang.c.chen@intel.com>
Signed-off-by: xiaojin2 <xiaojing.liu@intel.com>
Reviewed-by: Zhi Jin <zhi.jin@intel.com>
Reviewed-by: Liu Xinwu <xinwu.liu@intel.com>
Acked-by: Zhang Di <di.zhang@intel.com>
2018-06-21 11:29:20 +08:00

32 lines
503 B
C

/*
* Copyright (C) <2018> Intel Corporation
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef CLIENT_H
#define CLIENT_H
#define COMM_NAME_LEN 64
#define SOCKET_NAME "user_crash"
#include <stdio.h>
enum CrashPacketType {
/* Initial request from crash_dump */
kDumpRequest = 0,
/* Notification of a completed crash dump */
kCompletedDump,
/* Responses to kRequest */
kPerformDump
};
struct crash_packet {
enum CrashPacketType packet_type;
int pid;
char name[COMM_NAME_LEN];
};
#endif