#include <afsconfig.h>
#include <afs/param.h>
-
#include <stdio.h>
+#include <string.h>
#include <signal.h>
#include <math.h>
#include <afs/cmd.h>
#include <afs/xstat_fs.h>
#include <afs/xstat_cm.h>
+#include <roken.h>
#include "afsmonitor.h"
#include "afsmon-labels.h"
{ /*initLightObject */
struct onode *newlightp; /*Ptr to new light onode */
struct gator_light_crparams light_crparams; /*Light creation params */
- char *truncname; /*Truncated name, if needed */
- int name_len; /*True length of name */
/* the following debug statement floods the debug file */
#ifdef DEBUG_DETAILED
* received.
*/
light_crparams.onode_params.cr_type = GATOR_OBJ_LIGHT;
- name_len = strlen(a_name);
- if (name_len <= a_width)
- sprintf(light_crparams.onode_params.cr_name, "%s", a_name);
- else {
- /*
- * We need to truncate the given name, leaving a `*' at the end to
- * show us it's been truncated.
- */
- truncname = light_crparams.onode_params.cr_name;
- strncpy(truncname, a_name, a_width - 1);
- truncname[a_width - 1] = '*';
- truncname[a_width] = 0;
- }
+ if (a_width >= sizeof(light_crparams.onode_params.cr_name))
+ a_width = sizeof(light_crparams.onode_params.cr_name) - 1;
+
+ if (a_width < 1)
+ a_width = 1;
+
+ if (strlcpy(light_crparams.onode_params.cr_name, a_name, a_width + 1) >= a_width + 1)
+ /* The name is truncated, put a '*' at the end to note */
+ light_crparams.onode_params.cr_name[a_width - 1] = '*';
+
light_crparams.onode_params.cr_x = a_x;
light_crparams.onode_params.cr_y = a_y;
light_crparams.onode_params.cr_width = a_width;
}
if (import) {
- strcpy(caller.userID.name, name);
- strcpy(caller.userID.instance, instance);
+ strlcpy(caller.userID.name, name, sizeof(caller.userID.name));
+ strlcpy(caller.userID.instance, instance, sizeof(caller.userID.instance));
caller.max_ticket_lifetime = htonl(MAXKTCTICKETLIFETIME);
caller.flags = htonl(KAFNORMAL);
caller.user_expiration = htonl(NEVERDATE);
#include <afs/fsprobe.h> /*Interface for fsprobe module */
#include <afs/afsutil.h>
+#include <string.h>
+
/*
* Command line parameter indicies.
*/
struct onode *newlightp; /*Ptr to new light onode */
/*We only support curses right now */
struct gator_light_crparams light_crparams; /*Light creation params */
- char *truncname; /*Truncated name, if needed */
int name_len; /*True length of name */
if (scout_debug) {
if (scout_debug)
fprintf(scout_debugfd, "[%s] Name '%s' has %d chars\n", rn, a_name,
name_len);
- if (name_len <= a_width)
- sprintf(light_crparams.onode_params.cr_name, "%s", a_name);
- else {
- /*
- * We need to truncate the given name, leaving a `*' at the end to
- * show us it's been truncated.
- */
- truncname = light_crparams.onode_params.cr_name;
- strncpy(truncname, a_name, a_width - 1);
- truncname[a_width - 1] = '*';
- truncname[a_width] = 0;
- }
+
+ if (a_width >= sizeof(light_crparams.onode_params.cr_name))
+ a_width = sizeof(light_crparams.onode_params.cr_name) - 1;
+
+ if (strlcpy(light_crparams.onode_params.cr_name, a_name, a_width + 1) >= a_width + 1)
+ /* The name is truncated, put a '*' at the end to note */
+ light_crparams.onode_params.cr_name[a_width - 1] = '*';
+
light_crparams.onode_params.cr_x = a_x;
light_crparams.onode_params.cr_y = a_y;
light_crparams.onode_params.cr_width = a_width;