This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/* Parse notify payload buffer and return data into payload structure */
SilcNotifyPayload silc_notify_payload_parse(const unsigned char *payload,
/* Parse notify payload buffer and return data into payload structure */
SilcNotifyPayload silc_notify_payload_parse(const unsigned char *payload,
int ret;
SILC_LOG_DEBUG(("Parsing Notify payload"));
silc_buffer_set(&buffer, (unsigned char *)payload, payload_len);
int ret;
SILC_LOG_DEBUG(("Parsing Notify payload"));
silc_buffer_set(&buffer, (unsigned char *)payload, payload_len);
return NULL;
}
/* Encode notify payload with variable argument list. If `argc' is > 0
argument payloads will be associated to the notify payload. Variable
return NULL;
}
/* Encode notify payload with variable argument list. If `argc' is > 0
argument payloads will be associated to the notify payload. Variable
- argv_lens = silc_calloc(argc, sizeof(uint32));
- argv_types = silc_calloc(argc, sizeof(uint32));
-
+ if (!argv)
+ return NULL;
+ argv_lens = silc_calloc(argc, sizeof(SilcUInt32));
+ if (!argv_lens) {
+ silc_free(argv);
+ return NULL;
+ }
+ argv_types = silc_calloc(argc, sizeof(SilcUInt32));
+ if (!argv_types) {
+ silc_free(argv_lens);
+ silc_free(argv);
+ return NULL;
+ }
+
for (i = 0, k = 0; i < argc; i++) {
x = va_arg(ap, unsigned char *);
for (i = 0, k = 0; i < argc; i++) {
x = va_arg(ap, unsigned char *);
argv_lens[k] = x_len;
argv_types[k] = i + 1;
k++;
}
args = silc_argument_payload_encode(k, argv, argv_lens, argv_types);
argv_lens[k] = x_len;
argv_types[k] = i + 1;
k++;
}
args = silc_argument_payload_encode(k, argv, argv_lens, argv_types);
if (k) {
silc_buffer_pull(buffer, 5);
silc_buffer_format(buffer,
if (k) {
silc_buffer_pull(buffer, 5);
silc_buffer_format(buffer,
- len = 5 + (args ? args->len : 0);
- buffer = silc_buffer_alloc(len);
- silc_buffer_pull_tail(buffer, SILC_BUFFER_END(buffer));
+ len = 5 + (args ? silc_buffer_len(args) : 0);
+ buffer = silc_buffer_alloc_size(len);
+ if (!buffer)
+ return NULL;
if (args) {
silc_buffer_pull(buffer, 5);
silc_buffer_format(buffer,
if (args) {
silc_buffer_pull(buffer, 5);
silc_buffer_format(buffer,