diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2006-02-15 08:21:57 +0000 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2006-02-15 08:21:57 +0000 |
commit | 2924bca7d31d8e1b2ca239316b603082e0a4cb33 (patch) | |
tree | c28f0f8cc9728e852adb01f302d38815e2c0f4e7 /pand/main.c | |
parent | 65d1a12cfff5d53e535134dbf03eedcc02ffb589 (diff) |
Fix problems with the size limitation of netdev string
Diffstat (limited to 'pand/main.c')
-rw-r--r-- | pand/main.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/pand/main.c b/pand/main.c index c01bb6b6..2f258aa3 100644 --- a/pand/main.c +++ b/pand/main.c @@ -188,7 +188,9 @@ static int do_listen(void) while (!terminate) { socklen_t alen = sizeof(l2a); + char devname[16]; int nsk; + nsk = accept(sk, (struct sockaddr *) &l2a, &alen); if (nsk < 0) { syslog(LOG_ERR, "Accept failed. %s(%d)", @@ -207,14 +209,17 @@ static int do_listen(void) continue; } - if (!bnep_accept_connection(nsk, role, netdev)) { + strncpy(devname, netdev, 16); + devname[15] = '\0'; + + if (!bnep_accept_connection(nsk, role, devname)) { char str[40]; ba2str(&l2a.l2_bdaddr, str); syslog(LOG_INFO, "New connection from %s %s", str, netdev); - run_devup(netdev, str, sk, nsk); + run_devup(devname, str, sk, nsk); } else { syslog(LOG_ERR, "Connection failed. %s(%d)", strerror(errno), errno); @@ -624,7 +629,8 @@ int main(int argc, char **argv) break; case 'e': - strcpy(netdev, optarg); + strncpy(netdev, optarg, 16); + netdev[15] = '\0'; break; case 'n': |