Skip to content

Commit

Permalink
Fix 'adb backup' command line validation
Browse files Browse the repository at this point in the history
The host side wasn't properly checking for argument-list sufficiency
*after* removing any [-f filename] sequence.

Fixes bug 5164135

Change-Id: I7bc49e37ef168182088e0e664b6897dd2a088ebf
  • Loading branch information
Christopher Tate committed Aug 23, 2011
1 parent 5da9358 commit bb86bc5
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions adb/commandline.c
Original file line number Diff line number Diff line change
Expand Up @@ -579,9 +579,6 @@ static int backup(int argc, char** argv) {
int fd, outFd;
int i, j;

/* bare "adb backup" is not a valid command */
if (argc < 2) return usage();

/* find, extract, and use any -f argument */
for (i = 1; i < argc; i++) {
if (!strcmp("-f", argv[i])) {
Expand All @@ -598,6 +595,9 @@ static int backup(int argc, char** argv) {
}
}

/* bare "adb backup" or "adb backup -f filename" are not valid invocations */
if (argc < 2) return usage();

outFd = adb_open_mode(filename, O_WRONLY | O_CREAT | O_TRUNC, 0640);
if (outFd < 0) {
fprintf(stderr, "adb: unable to open file %s\n", filename);
Expand Down

0 comments on commit bb86bc5

Please sign in to comment.