Skip to content

Commit

Permalink
Don't crash if the user provides -s without a pid.
Browse files Browse the repository at this point in the history
Reported-by: Michael Orlitzky <michael@orlitzky.com>
  • Loading branch information
nelhage committed Mar 8, 2011
1 parent 2d1a9e5 commit 919fff7
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions reptyr.c
Expand Up @@ -199,6 +199,12 @@ int main(int argc, char **argv) {
}
}

if (do_attach && arg >= argc) {
fprintf(stderr, "%s: No pid specified to attach\n", argv[0]);
usage(argv[0]);
return 1;
}

if ((pty = open("/dev/ptmx", O_RDWR|O_NOCTTY)) < 0)
die("Unable to open /dev/ptmx: %m");
if (unlockpt(pty) < 0)
Expand Down

0 comments on commit 919fff7

Please sign in to comment.