From 999847c8e631a53b258e0f59fe3bacbba6477c99 Mon Sep 17 00:00:00 2001
From: Guido Trotter <ultrotter@google.com>
Date: Mon, 31 May 2010 18:45:46 +0200
Subject: [PATCH] ssconf: error out when writing oversized files

Since we impose a maximum limit when reading ssconf files, let's error
out when trying to write them too big, so we don't pretend everything is
ok, and make mistakes when we actually read partial files.

Signed-off-by: Guido Trotter <ultrotter@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>
---
 lib/ssconf.py | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lib/ssconf.py b/lib/ssconf.py
index 9fa088e1b..035a88703 100644
--- a/lib/ssconf.py
+++ b/lib/ssconf.py
@@ -336,6 +336,9 @@ class SimpleStore(object):
       for name, value in values.iteritems():
         if value and not value.endswith("\n"):
           value += "\n"
+        if len(value) > self._MAX_SIZE:
+          raise errors.ConfigurationError("ssconf file %s above maximum size" %
+                                          name)
         utils.WriteFile(self.KeyToFilename(name), data=value, mode=0444)
     finally:
       ssconf_lock.Unlock()
-- 
GitLab