system-controller: fix user name handling.
authorIsmo Puustinen <ismo.puustinen@intel.com>
Thu, 16 Oct 2014 07:37:23 +0000 (10:37 +0300)
committerKrisztian Litkey <krisztian.litkey@intel.com>
Thu, 8 Jan 2015 16:37:18 +0000 (18:37 +0200)
Change-Id: I72d95e3e3c052394ca5a35170bc718dfc1ace6bf

src/plugins/system-controller/user/user.c

index 0cc22d5..0b37764 100644 (file)
@@ -316,11 +316,18 @@ static char *get_last_user(const char *user_dir)
     last_user_file = fopen(last_user_file_buf, "r");
 
     if (last_user_file) {
-        ret = fread(last_user_buf, sizeof(last_user_buf), 1, last_user_file);
+
+        memset(last_user_buf, 0, sizeof(last_user_buf));
+
+        ret = fread(last_user_buf, 1, sizeof(last_user_buf), last_user_file);
 
         if (ret < 0) {
             goto end;
         }
+        else if (ret == 512) {
+            /* too much data */
+            goto end;
+        }
 
         mrp_log_info("system-controller: last user '%s'", last_user_buf);