Skip to content

Commit

Permalink
Fix compiler warnings and non-NULL terminated process name
Browse files Browse the repository at this point in the history
Signed-off-by: Yongkui Han <yonhan@cisco.com>
  • Loading branch information
yonhan3 committed Jan 14, 2024
1 parent 339c687 commit d1bd20c
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.6
1.0.7
20 changes: 10 additions & 10 deletions configure
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69 for openosc 1.0.5.
# Generated by GNU Autoconf 2.69 for openosc 1.0.7.
#
# Report bugs to <yonhan@cisco.com>.
#
Expand Down Expand Up @@ -590,8 +590,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='openosc'
PACKAGE_TARNAME='openosc'
PACKAGE_VERSION='1.0.5'
PACKAGE_STRING='openosc 1.0.5'
PACKAGE_VERSION='1.0.7'
PACKAGE_STRING='openosc 1.0.7'
PACKAGE_BUGREPORT='yonhan@cisco.com'
PACKAGE_URL=''

Expand Down Expand Up @@ -1329,7 +1329,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures openosc 1.0.5 to adapt to many kinds of systems.
\`configure' configures openosc 1.0.7 to adapt to many kinds of systems.

Usage: $0 [OPTION]... [VAR=VALUE]...

Expand Down Expand Up @@ -1399,7 +1399,7 @@ fi

if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of openosc 1.0.5:";;
short | recursive ) echo "Configuration of openosc 1.0.7:";;
esac
cat <<\_ACEOF

Expand Down Expand Up @@ -1508,7 +1508,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
openosc configure 1.0.5
openosc configure 1.0.7
generated by GNU Autoconf 2.69

Copyright (C) 2012 Free Software Foundation, Inc.
Expand Down Expand Up @@ -1998,7 +1998,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.

It was created by openosc $as_me 1.0.5, which was
It was created by openosc $as_me 1.0.7, which was
generated by GNU Autoconf 2.69. Invocation command line was

$ $0 $@
Expand Down Expand Up @@ -2861,7 +2861,7 @@ fi

# Define the identity of the package.
PACKAGE='openosc'
VERSION='1.0.5'
VERSION='1.0.7'


cat >>confdefs.h <<_ACEOF
Expand Down Expand Up @@ -16738,7 +16738,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by openosc $as_me 1.0.5, which was
This file was extended by openosc $as_me 1.0.7, which was
generated by GNU Autoconf 2.69. Invocation command line was

CONFIG_FILES = $CONFIG_FILES
Expand Down Expand Up @@ -16804,7 +16804,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
openosc config.status 1.0.5
openosc config.status 1.0.7
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"

Expand Down
4 changes: 3 additions & 1 deletion include/openosc_fortify.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@
#define __dst_overflow_msg(func) func " caller with bigger length than size of destination buffer"
#define __src_overread_msg(func) func " caller with bigger length than size of source buffer, will cause src overread"

#define __OPENOSC_CLANG_CC (defined __clang__ && __clang_major__ >= 5)
#define __OPENOSC_CLANG_CC 0

/* For clang compiler support */
#if defined __clang__
Expand All @@ -238,6 +238,8 @@
#define __pass_objsize1
#define __openosc_fortify_function __fortify_function
#else
#undef __OPENOSC_CLANG_CC
#define __OPENOSC_CLANG_CC 1
#define __clang_error_if(c, m) __attribute__ ((__diagnose_if__ ((c), (m), "error")))
#define __clang_warning_if(c, m) __attribute__ ((__diagnose_if__ ((c), (m), "warning")))
#define __pass_objsize0 const __attribute__((pass_object_size(0)))
Expand Down
6 changes: 3 additions & 3 deletions src/openosc_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ __openosc_memcpy_to_buf(size_t dest_len, size_t src_len, void *dst, const void *
abort();
}
if (openosc_truncate) {
if (dest_len <= 0) {
if ((dest_len == (size_t) -1) || (dest_len == 0)) {
len = src_len;
} else {
len = MIN(src_len, dest_len);
Expand Down Expand Up @@ -84,7 +84,7 @@ __openosc_memmove_to_buf(size_t dest_len, size_t src_len, void *dst, const void
abort();
}
if (openosc_truncate) {
if (dest_len <= 0) {
if ((dest_len == (size_t) -1) || (dest_len == 0)) {
len = src_len;
} else {
len = MIN(src_len, dest_len);
Expand Down Expand Up @@ -148,7 +148,7 @@ __openosc_bcopy_to_buf(size_t dest_len, size_t src_len, const void *src, void *d
abort();
}
if (openosc_truncate) {
if (dest_len <= 0) {
if ((dest_len == (size_t) -1) || (dest_len == 0)) {
len = src_len;
} else {
len = MIN(src_len, dest_len);
Expand Down
10 changes: 4 additions & 6 deletions src/openosc_support.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,16 @@ openosc_get_process_name(char *name, int name_len)
{
char path[OSC_PROC_PATH_MAX];
FILE* fd;
size_t size;

if (!name)
return FALSE;

snprintf(path, OSC_PROC_PATH_MAX, "/proc/%d/cmdline", getpid());
fd = fopen(path, "r");
if (fd != NULL) {
size = fread((void *)name, sizeof(char), name_len, fd);
size_t size = fread((void *)name, sizeof(char), name_len, fd);
if (size > 0) {
if('\n' == name[size-1])
name[size-1]='\0';
name[size-1]='\0';
}
fclose(fd);
return TRUE;
Expand Down Expand Up @@ -129,14 +127,14 @@ openosc_bt2str_offset (void *bt[], int frames, char *bt_str,
* If the symbol is in us, just print the offset
*/
s += snprintf(&bt_str[s], (bt_str_max - s), "+%p ",
(void *)(bt[f] - info.dli_fbase));
(void *)((char *)bt[f] - (char *)info.dli_fbase));
} else {
bname = basename(info.dli_fname);
/*
* Otherwise print library+offset
*/
s += snprintf(&bt_str[s], (bt_str_max - s), "%s+%p ",
bname, (void *)(bt[f] - info.dli_fbase));
bname, (void *)((char *)bt[f] - (char *)info.dli_fbase));
}
}
}
Expand Down

0 comments on commit d1bd20c

Please sign in to comment.