Don't crash when installing a service.
authorIain Patterson <me@iain.cx>
Thu, 13 Feb 2014 18:52:55 +0000 (18:52 +0000)
committerIain Patterson <me@iain.cx>
Thu, 13 Feb 2014 18:52:55 +0000 (18:52 +0000)
install_service() calls edit_service() with a null username, causing
well_known_username() to segfault.

Thanks Czenda Czendov.

account.cpp

index 5e6523f..19dc66e 100644 (file)
@@ -166,6 +166,7 @@ const TCHAR *well_known_sid(SID *sid) {
 }
 
 const TCHAR *well_known_username(const TCHAR *username) {
+  if (! username) return NSSM_LOCALSYSTEM_ACCOUNT;
   if (str_equiv(username, NSSM_LOCALSYSTEM_ACCOUNT)) return NSSM_LOCALSYSTEM_ACCOUNT;
   SID *sid;
   int r = username_sid(username, &sid);