From: Eugene Syromyatnikov Date: Tue, 16 Jan 2018 16:38:35 +0000 (+0100) Subject: syscall.c: add sanity check for the target personality number X-Git-Tag: v4.21~134 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a4886a7f99db432470d6737c90c3845a5feb5ecd;p=strace syscall.c: add sanity check for the target personality number We can never be cautious enough. * defs.h (set_personality): Change argument type to unsigned int. * syscall.c (set_personality): Change argument type to unsigned int, check whether requested personality is sane, die otherwise. --- diff --git a/defs.h b/defs.h index 2d9793e4..7f8a1054 100644 --- a/defs.h +++ b/defs.h @@ -816,7 +816,7 @@ extern void tprintf_comment(const char *fmt, ...) ATTRIBUTE_FORMAT((printf, 1, 2 extern void tprints_comment(const char *str); #if SUPPORTED_PERSONALITIES > 1 -extern void set_personality(int personality); +extern void set_personality(unsigned int personality); extern unsigned current_personality; #else # define set_personality(personality) ((void)0) diff --git a/syscall.c b/syscall.c index 67f6eaee..444bfa1e 100644 --- a/syscall.c +++ b/syscall.c @@ -252,11 +252,15 @@ static const int personality_klongsize[SUPPORTED_PERSONALITIES] = { # endif void -set_personality(int personality) +set_personality(unsigned int personality) { if (personality == current_personality) return; + if (personality >= SUPPORTED_PERSONALITIES) + error_msg_and_die("Requested switch to unsupported personality " + "%u", personality); + nsyscalls = nsyscall_vec[personality]; sysent = sysent_vec[personality];