]> git.ipfire.org Git - thirdparty/snapper.git/commitdiff
- check input
authorArvin Schnell <aschnell@suse.de>
Tue, 9 Aug 2011 13:04:24 +0000 (15:04 +0200)
committerArvin Schnell <aschnell@suse.de>
Tue, 9 Aug 2011 13:04:24 +0000 (15:04 +0200)
tools/snapper.cc

index 8169cb7a5ee3f277c7529229aace58a6a2ee1e17..b790154e581ed27408364b08de6d7cc24d7d9379 100644 (file)
@@ -173,9 +173,15 @@ readNum(const string& str)
 {
     Snapshots& snapshots = sh->getSnapshots();
 
+    istringstream s(str);
     unsigned int num = 0;
-    if (str != "current")
-       str >> num;
+    s >> num;
+
+    if (s.fail() || !s.eof())
+    {
+       cerr << sformat(_("Invalid snapshot '%s'."), str.c_str()) << endl;
+       exit(EXIT_FAILURE);
+    }
 
     Snapshots::iterator snap = snapshots.find(num);
     if (snap == snapshots.end())