#include <atalk/dsi.h>
#include <atalk/unicode.h>
#include <atalk/util.h>
+#include <atalk/globals.h>
-#include "globals.h" /* includes <netdb.h> */
#include "status.h"
#include "afp_config.h"
#include "icon.h"
char *start = data;
char *Obj, *Type, *Zone;
char buf[32];
- u_int16_t status;
+ uint16_t status;
size_t len;
/* make room for all offsets before server name */
static void status_machine(char *data)
{
char *start = data;
- u_int16_t status;
+ uint16_t status;
int len;
#ifdef AFS
const char *machine = "afs";
#else /* !AFS */
- const char *machine = "Netatalk %s";
+ const char *machine = "Netatalk%s";
#endif /* AFS */
- char buf[64];
+ char buf[AFPSTATUS_MACHLEN+1];
memcpy(&status, start + AFPSTATUS_MACHOFF, sizeof(status));
data += ntohs( status );
- // len = strlen( machine );
- len = snprintf(buf, 64, machine, VERSION);
+ if ((strlen(machine) + strlen(VERSION)) <= AFPSTATUS_MACHLEN) {
+ len = snprintf(buf, AFPSTATUS_MACHLEN + 1, machine, VERSION);
+ } else {
+ if (strlen(VERSION) > AFPSTATUS_MACHLEN) {
+ len = snprintf(buf, AFPSTATUS_MACHLEN + 1, VERSION);
+ } else {
+ (void)snprintf(buf, AFPSTATUS_MACHLEN + 1, machine, "");
+ (void)snprintf(buf + AFPSTATUS_MACHLEN - strlen(VERSION),
+ strlen(VERSION) + 1,
+ VERSION);
+ len = AFPSTATUS_MACHLEN;
+ }
+ }
+
*data++ = len;
memcpy( data, buf, len );
data += len;
}
/* server signature is a 16-byte quantity */
-static u_int16_t status_signature(char *data, int *servoffset,
+static uint16_t status_signature(char *data, int *servoffset,
const struct afp_options *options)
{
char *status;
- u_int16_t offset, sigoff;
+ uint16_t offset, sigoff;
status = data;
const struct afp_options *options)
{
char *begin;
- u_int16_t offset;
+ uint16_t offset;
size_t addresses_len = 0;
begin = data;
const struct afp_options *options)
{
char *begin = data;
- u_int16_t offset;
+ uint16_t offset;
memcpy(&offset, data + *diroffset, sizeof(offset));
offset = ntohs(offset);
data += offset;
}
/* Calculate and store offset for UTF8ServerName */
- *diroffset += sizeof(u_int16_t);
+ *diroffset += sizeof(uint16_t);
offset = htons(data - begin);
- memcpy(begin + *diroffset, &offset, sizeof(u_int16_t));
+ memcpy(begin + *diroffset, &offset, sizeof(uint16_t));
/* return length of buffer */
return (data - begin);
const struct afp_options *options)
{
char *Obj, *Type, *Zone;
- u_int16_t namelen;
+ uint16_t namelen;
size_t len;
char *begin = data;
- u_int16_t offset, status;
+ uint16_t offset, status;
memcpy(&offset, data + *nameoffset, sizeof(offset));
offset = ntohs(offset);
data += sizeof(namelen);
data += len;
offset = htons(offset);
- memcpy(begin + *nameoffset, &offset, sizeof(u_int16_t));
+ memcpy(begin + *nameoffset, &offset, sizeof(uint16_t));
}
/* return length of buffer */
{
char *start = data;
char *sigdata = data + sigoffset;
- u_int16_t ret, status;
+ uint16_t ret, status;
memcpy(&status, start + AFPSTATUS_ICONOFF, sizeof(status));
if ( icondata == NULL ) {
if (dsiconfig) {
status = dsiconfig->status;
maxstatuslen=sizeof(dsiconfig->status);
- dsi = dsiconfig->obj.handle;
+ dsi = dsiconfig->obj.dsi;
if (dsi->server.ss_family == AF_INET) { /* IPv4 */
const struct sockaddr_in *sa4 = (struct sockaddr_in *)&dsi->server;
ipok = sa4->sin_addr.s_addr ? 1 : 0;