From: Todd C. Miller Date: Tue, 13 May 2014 20:18:06 +0000 (-0600) Subject: In -x mode, require that the input and output files be different. X-Git-Tag: SUDO_1_8_11^2~187 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=372e30851fd85208dcf10f5fe2ce5bb4fcf98b60;p=sudo In -x mode, require that the input and output files be different. This won't currently catch collisions between the output file and an include file. --- diff --git a/plugins/sudoers/visudo_json.c b/plugins/sudoers/visudo_json.c index 432d5a58d..4ee5e20af 100644 --- a/plugins/sudoers/visudo_json.c +++ b/plugins/sudoers/visudo_json.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Todd C. Miller + * Copyright (c) 2013-2014 Todd C. Miller * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -1026,6 +1026,13 @@ export_sudoers(const char *sudoers_path, const char *export_path, goto done; } if (strcmp(export_path, "-") != 0) { + if (strcmp(sudoers_path, export_path) == 0) { + if (!quiet) { + warningx(U_("%s: input and output files must be different"), + sudoers_path); + } + goto done; + } if ((export_fp = fopen(export_path, "w")) == NULL) { if (!quiet) warning(U_("unable to open %s"), export_path);