use 'test -n "..."' instead of 'test "..."'; when "..." expands to '-v'
[util-vserver.git] / util-vserver / src / save_ctxinfo.c
index d91d884..cfb26fa 100644 (file)
@@ -75,8 +75,9 @@ int main(int argc, char *argv[])
     return 255;
   }
 
-  EreadlinkD(runfile, dstfile, sizeof(dstfile));
-  len  = utilvserver_fmt_uint(buf, ctx);
+  len          = EreadlinkD(runfile, dstfile, sizeof(dstfile)-1);
+  dstfile[len] = '\0';
+  len          = utilvserver_fmt_uint(buf, ctx);
 
   fd = EopenD(dstfile, O_EXCL|O_CREAT|O_WRONLY, 0644);
   if (write(fd, buf,     len) !=len  ||
@@ -87,7 +88,7 @@ int main(int argc, char *argv[])
   Eclose(fd);
 
   strcat(runfile, ".rev/");
-  strcat(runfile, buf);
+  strncat(runfile, buf, len);
   unlink(runfile);
   EsymlinkD(argv[1], runfile);