]> granicus.if.org Git - sudo/commitdiff
In -x mode, require that the input and output files be different.
authorTodd C. Miller <Todd.Miller@courtesan.com>
Tue, 13 May 2014 20:18:06 +0000 (14:18 -0600)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Tue, 13 May 2014 20:18:06 +0000 (14:18 -0600)
This won't currently catch collisions between the output file
and an include file.

plugins/sudoers/visudo_json.c

index 432d5a58dae8f85ae34f62bc46a00e02fe9e9ed1..4ee5e20afcf0283fb948c3701044a9d2ad87f569 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013 Todd C. Miller <Todd.Miller@courtesan.com>
+ * Copyright (c) 2013-2014 Todd C. Miller <Todd.Miller@courtesan.com>
  *
  * 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);