aboutsummaryrefslogtreecommitdiffstats
path: root/tools/ipc-modem.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/ipc-modem.c')
-rw-r--r--tools/ipc-modem.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/tools/ipc-modem.c b/tools/ipc-modem.c
index c85c812..2b19f57 100644
--- a/tools/ipc-modem.c
+++ b/tools/ipc-modem.c
@@ -18,6 +18,7 @@
* along with libsamsung-ipc. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <assert.h>
#include <fcntl.h>
#include <getopt.h>
#include <pthread.h>
@@ -511,17 +512,17 @@ int main(int argc, char *argv[])
} else if (strcmp(opt_l[opt_i].name, "debug") == 0) {
debug = 1;
printf("[I] Debug enabled\n");
- } else if (strcmp(opt_l[opt_i].name, "pin") == 0) {
- if (optarg) {
- if (strlen(optarg) < 8) {
- printf("[I] Got SIM PIN!\n");
- memcpy(sim_pin, optarg, 8);
- } else {
- printf("[E] "
- "SIM PIN is too long!"
- "\n");
- return 1;
- }
+ } else if ((strcmp(opt_l[opt_i].name, "pin") == 0) &&
+ (optarg)) {
+ if (strlen(optarg) < 8) {
+ assert(strlen(optarg) <
+ sizeof(sim_pin));
+
+ printf("[I] Got SIM PIN!\n");
+ strcpy(sim_pin, optarg);
+ } else {
+ printf("[E] SIM PIN is too long!\n");
+ return 1;
}
}
break;