diff --git a/src/files.c b/src/files.c index 63a403ce..c0efa32e 100644 --- a/src/files.c +++ b/src/files.c @@ -333,13 +333,20 @@ int do_lockfile(const char *filename, bool ask_the_user) close(lockfd); - if (readtot < 48) { + if (readtot < 1024) { statusline(MILD, _("Error reading lock file %s: " "Not enough data read"), lockfilename); free(lockbuf); goto free_the_name; } + if (lockbuf[0] != 0x62 || lockbuf[1] != 0x30) { + statusline(ALERT, _("Bad lock file is ignored: %s"), lockfilename); + free(lockbuf); + retval = 0; + goto free_the_name; + } + strncpy(lockprog, &lockbuf[2], 10); lockpid = (((unsigned char)lockbuf[27] * 256 + (unsigned char)lockbuf[26]) * 256 + (unsigned char)lockbuf[25]) * 256 + (unsigned char)lockbuf[24];