Commit Graph

44 Commits

Author SHA1 Message Date
079c2abf8e Update License consistently to GPLv2 as per COPYING file 2020-10-05 10:13:12 +02:00
95012d6259 Avoid hardcoding of buffer size 2020-09-17 21:43:05 +02:00
6921000481 Barely ever seen any 1000 digit PIDs … 2020-09-17 21:43:05 +02:00
9207401f97 Clean up some code duplication in the header files
PR htop-dev/htop#70 got rid of the infrastructure for generating header
files, but it left behind some code duplication.

Some of cases are things that belong in the header file and don't need
to be repeated in the C file. Other cases are things that belong in the
C file and don't need to be in the header file.

In this commit I tried to fix all of these that I could find. When given
a choice I preferred keeping things out of the header file, unless they
were being used by someone else.
2020-09-12 19:20:44 -03:00
a1a027b9bd Axe automated header generation.
Reasoning:
 - implementation was unsound -- broke down when I added a fairly
   basic macro definition expanding to a struct initializer in a *.c
   file.

 - made it way too easy (e.g. via otherwise totally innocuous git
   commands) to end up with timestamps such that it always ran
   MakeHeader.py but never used its output, leading to overbuild noise
   when running what should be a null 'make'.

 - but mostly: it's just an awkward way of dealing with C code.
2020-09-03 11:58:58 -05:00
c3fadf6b69 Add timestamps to the strace screen 2019-04-29 15:17:05 +02:00
aa3dc634dc strace: increase string length 2018-03-25 15:14:04 -03:00
8c653212c0 Replace size_t with int/void* union
I was occasionally passing negative values to size_t.
Plus, this better reflects the intent of the variant argument.

Reported by Coverity:
https://scan8.coverity.com/reports.htm#v13253/p10402/fileInstanceId=22093891&defectInstanceId=7543346&mergedDefectId=174179&fileStart=251&fileEnd=500
2018-02-18 10:38:49 -03:00
09e241fb12 Security review: check results of snprintf.
Calls marked with xSnprintf shouldn't fail.
Abort program cleanly if any of them does.
2017-07-27 16:07:50 -03:00
3975e9ce5c Merge branch 'master' of https://github.com/hishamhm/htop 2017-07-26 16:16:10 -03:00
543d65c6ab Security review: make privilege dropping-restoring optional.
This is/was necessary only on macOS, because you needed root in order
to read the process list. This was never necessary on Linux, and
it also raises security concerns, so now it needs to be enabled
explicitly at build time.
2017-07-26 15:40:55 -03:00
d5faf64374 Mark some things as const
Several string pointer arrays pointed to const strings
but were not const themselves.

A few various structures and arrays were also marked const.
2017-07-22 22:34:30 -05:00
53d7c66ac3 Add missing include
sys/time.h for struct timeval
2017-03-25 14:12:26 +03:00
2b5c1b4b13 Replace all uses of sprintf with snprintf
In all the cases where sprintf was being used within htop, snprintf
could have been used. This patch replaces all uses of sprintf with
snprintf which makes sure that if a buffer is too small to hold the
resulting string, the string is simply cut short instead of causing
a buffer overflow which leads to undefined behaviour.

`sizeof(variable)` was used in these cases, as opposed to `sizeof
variable` which is my personal preference because `sizeof(variable)`
was already used in one way or another in other parts of the code.
2016-12-29 19:42:41 +01:00
fa0c637c55 Silence warnings about seteuid return value.
Closes #483.
2016-05-25 21:37:07 -03:00
b54d2dde40 Check for failure in allocations. 2016-02-02 15:53:02 +01:00
466d4da0c6 refactor *Screen classes, add InfoScreen superclass 2016-01-12 06:00:58 -02:00
d18e9a4895 add some security checks when running SUID root
on Darwin, htop needs to run with root privileges to display information
about other users processes. This commit makes running htop SUID root a
bit more safe.
2015-12-02 22:56:01 +01:00
445222e48c Clean up some needless malloc casts, convert some mallocs to callocs, and fix some style 2015-09-16 23:42:36 -04:00
5e602f18d5 Rename String to StringUtils.
Fixes building on case-insensitive filesystems where String.h gets confused with <string.h>.

From d734dacea0a10d0465dad4e95b3421511e7da112 Mon Sep 17 00:00:00 2001
From: David Hunt <dhunt@iolanthe.attlocal.net>
Date: Sat, 11 Jul 2015 20:56:31 -0500
Subject: [PATCH 1/8] Rename String to StringUtils
2015-08-19 13:45:20 -03:00
08829cbc3b fix compiler warnings
gcc gives warnings like this:

warning: ignoring return value of ‘fscanf’, declared with attribute
warn_unused_result

Assign value to a variable, cast to (void) to discard it.
2015-05-15 11:33:25 +02:00
ade7993fcb incremental search and filter reintegrated! 2015-03-23 17:04:53 -03:00
d0c72c3fb2 Move FunctionBar inside Panel 2015-03-23 15:26:56 -03:00
1afbc19087 safer code, test for return of fcntl 2014-04-22 20:35:44 -03:00
00b324bfc1 Changes in object model: separate class objects to store vtable. Also, nicer UTF-8 display of big numbers. 2012-12-05 15:12:20 +00:00
2a73405cd0 search and filter for the strace and lsof screens! 2012-11-10 00:31:37 +00:00
8b73d11ac6 make htop trunk compile on FreeBSD 8.2-STABLE
(thanks to Trond Endestrol)
2012-01-03 18:19:11 +00:00
84281bdc44 major header cleanup 2011-12-26 21:35:57 +00:00
ec17b7029a Convert affinity control from the deprecated PLPA to HWLOC 2011-09-24 00:30:47 +00:00
6486229308 add support for steal/guest CPU time measurement
simplify processor data accounting (add CPUData structure)
remove Process_clone trick
2010-08-24 23:20:38 +00:00
0b0bd25e42 home and end keys in trace screens 2010-07-31 00:11:34 +00:00
02a30bfecd warning fixes 2010-02-25 01:43:18 +00:00
3e6be2d7f7 fix to minor bug affecting the build process, a maintenance release will follow shortly. 2009-06-08 21:08:02 +00:00
6330ff3a0a changes for htop 0.8.2 2009-06-02 04:51:23 +00:00
da23c8c5a1 Clean up headers by using 'static' whenever possible.
Reduces resulting code size.
2008-03-09 08:58:38 +00:00
cc5af25e11 Fix bug 1538463. 2006-08-24 21:28:29 +00:00
5d48ab8c28 Performance improvement hackathon: improve process comparison routines,
disable useless code in release builds such as runtime type-checking on
dynamic data structures and process fields that are not being computed,
faster(?) method for verifying the process owner (still need to ensure
correctness), don't destroy and create process objects for hidden kernel
threads over and over. Phew. I shouldn't be doing all this today, but I
could not resist.
2006-07-11 06:13:32 +00:00
2f1f82ee87 Updates for new version of the MakeHeader.py script. 2006-06-06 20:41:01 +00:00
8bc180b7d1 Display error message when strace is not available.
Mark autogen.sh executable in svn.
2006-06-03 23:14:09 +00:00
ea855aef73 Remove references to ListBox 2006-05-30 14:00:18 +00:00
c2cdcd0c1d Rename ListBox to Panel, matching dit. 2006-05-30 13:47:28 +00:00
9d5cc90497 Wait for strace child process to die properly 2006-05-09 17:58:40 +00:00
130938f691 Fixes for header generation. 2006-03-23 18:55:29 +00:00
d6231bab89 Initial import. 2006-03-04 18:16:49 +00:00