Skip to content

Commit 977bacd

Browse files
committed
Merge branch 'devel'
2 parents c310d35 + fcea27b commit 977bacd

2 files changed

Lines changed: 10 additions & 6 deletions

File tree

src/messages_server.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <stdlib.h>
1717
#include <string.h>
1818
#include <stdarg.h>
19+
#include <stdbool.h>
1920

2021
#include <libyang/libyang.h>
2122

@@ -828,6 +829,7 @@ nc_server_notif_new(struct lyd_node* event, char *eventtime, NC_PARAMTYPE paramt
828829
{
829830
struct nc_server_notif *ntf;
830831
struct lyd_node *elem;
832+
bool found_notif = false;
831833

832834
if (!event) {
833835
ERRARG("event");
@@ -838,7 +840,7 @@ nc_server_notif_new(struct lyd_node* event, char *eventtime, NC_PARAMTYPE paramt
838840
}
839841

840842
/* check that there is a notification */
841-
for (elem = event; elem && (elem->schema->nodetype != LYS_NOTIF); elem = elem->child) {
843+
for (elem = event; elem && !found_notif; elem = elem->child) {
842844
next_node:
843845
switch (elem->schema->nodetype) {
844846
case LYS_LEAF:
@@ -852,16 +854,18 @@ nc_server_notif_new(struct lyd_node* event, char *eventtime, NC_PARAMTYPE paramt
852854
goto next_node;
853855
case LYS_CONTAINER:
854856
case LYS_LIST:
855-
case LYS_NOTIF:
856857
/* ok */
857858
break;
859+
case LYS_NOTIF:
860+
found_notif = true;
861+
break;
858862
default:
859863
/* error */
860864
ERRARG("event");
861865
return NULL;
862866
}
863867
}
864-
if (!elem) {
868+
if (!found_notif) {
865869
ERRARG("event");
866870
return NULL;
867871
}

src/session_server.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -369,9 +369,9 @@ nc_sock_accept_binds(struct nc_bind *binds, uint16_t bind_count, int timeout, ch
369369
/* host was requested */
370370
if (host) {
371371
if (saddr.ss_family == AF_INET) {
372-
*host = malloc(15);
372+
*host = malloc(INET_ADDRSTRLEN);
373373
if (*host) {
374-
if (!inet_ntop(AF_INET, &((struct sockaddr_in *)&saddr)->sin_addr.s_addr, *host, 15)) {
374+
if (!inet_ntop(AF_INET, &((struct sockaddr_in *)&saddr)->sin_addr.s_addr, *host, INET_ADDRSTRLEN)) {
375375
ERR("inet_ntop failed (%s).", strerror(errno));
376376
free(*host);
377377
*host = NULL;
@@ -386,7 +386,7 @@ nc_sock_accept_binds(struct nc_bind *binds, uint16_t bind_count, int timeout, ch
386386
} else if (saddr.ss_family == AF_INET6) {
387387
*host = malloc(INET6_ADDRSTRLEN);
388388
if (*host) {
389-
if (!inet_ntop(AF_INET6, ((struct sockaddr_in6 *)&saddr)->sin6_addr.s6_addr, *host, 40)) {
389+
if (!inet_ntop(AF_INET6, ((struct sockaddr_in6 *)&saddr)->sin6_addr.s6_addr, *host, INET6_ADDRSTRLEN)) {
390390
ERR("inet_ntop failed (%s).", strerror(errno));
391391
free(*host);
392392
*host = NULL;

0 commit comments

Comments
 (0)