Skip to content

Commit

Permalink
wget.c: replace deprecated gets with safe fgets
Browse files Browse the repository at this point in the history
  • Loading branch information
simonduq committed Nov 10, 2015
1 parent fbd78a7 commit dacef46
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions examples/wget/wget.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,14 +169,14 @@ PROCESS_THREAD(wget_process, ev, data)
strcpy(url, contiki_argv[1]);
puts(url);
} else {
gets(url);
fgets(url, sizeof(url), stdin);
}
fputs("Save as:", stdout);
if(contiki_argc > 2) {
strcpy(name, contiki_argv[2]);
puts(name);
} else {
gets(name);
fgets(name, sizeof(name), stdin);
}
file = cfs_open(name, CFS_WRITE);
if(file == -1) {
Expand Down

3 comments on commit dacef46

@oliverschmidt
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You broke the code with this change as fgets() stores the terminating newline char in the string while gets() didn't :-(

@oliverschmidt
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now fixed.

@simonduq
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry for the bug, thanks for the fix!

Please sign in to comment.