font_count++;
}
if (strlen(data_in) > 1) {
- strncpy(fonts[0].name, data_in, text_buffer_size);
+ strncpy(fonts[0].name, data_in, DEFAULT_TEXT_BUFFER_SIZE);
#ifdef XFT
fonts[0].font_alpha = 0xffff;
#endif
static char *scan_font(const char *args)
{
if (args && *args) {
- return strndup(args, text_buffer_size);
+ return strndup(args, DEFAULT_TEXT_BUFFER_SIZE);
}
return NULL;
unsigned int *scale)
{
char buf[64];
+ buf[0] = 0;
/* zero width means all space that is available */
*w = 0;
case OBJ_hddtemp:
free(objs[i].data.hddtemp.dev);
free(objs[i].data.hddtemp.addr);
+ free(objs[i].data.hddtemp.temp);
break;
#endif
case OBJ_entropy_avail:
#ifdef HDDTEMP
END OBJ(hddtemp, 0)
if (!arg || scan_hddtemp(arg, &obj->data.hddtemp.dev,
- &obj->data.hddtemp.addr, &obj->data.hddtemp.port)) {
+ &obj->data.hddtemp.addr, &obj->data.hddtemp.port, &obj->data.hddtemp.temp)) {
ERR("hddtemp needs arguments");
obj->type = OBJ_text;
obj->data.s = strndup("${hddtemp}", text_buffer_size);
#ifdef HDDTEMP
OBJ(hddtemp) {
if (obj->data.hddtemp.update_time < current_update_time - 30) {
- obj->data.hddtemp.temp = get_hddtemp_info(obj->data.hddtemp.dev,
+ char *str = get_hddtemp_info(obj->data.hddtemp.dev,
obj->data.hddtemp.addr, obj->data.hddtemp.port, &obj->data.hddtemp.unit);
+ if (str) {
+ strncpy(obj->data.hddtemp.temp, str, text_buffer_size);
+ } else {
+ obj->data.hddtemp.temp[0] = 0;
+ }
obj->data.hddtemp.update_time = current_update_time;
}
if (!obj->data.hddtemp.temp) {
/* in hddtemp.c */
#ifdef HDDTEMP
-int scan_hddtemp(const char *arg, char **dev, char **addr, int *port);
+int scan_hddtemp(const char *arg, char **dev, char **addr, int *port, char **temp);
char *get_hddtemp_info(char *dev, char *addr, int port, char *unit);
#endif /* HDDTEMP */
char buf[BUFLEN];
-int scan_hddtemp(const char *arg, char **dev, char **addr, int *port)
+int scan_hddtemp(const char *arg, char **dev, char **addr, int *port, char** temp)
{
char buf1[32], buf2[64];
int n, ret;
*port = PORT;
}
+ *temp = malloc(text_buffer_size);
+ memset(*temp, 0, text_buffer_size);
+
return 0;
}
p++;
*unit = *p;
if (!strncmp(out, "NA", 2)) {
- strcpy(buf, "N/A");
+ strncpy(buf, "N/A", BUFLEN);
r = buf;
} else {
r = out;
}
p++;
}
+ if (!p && i < 5) {
+ break;
+ }
}
}
} while (0);
if (!XParseColor(display, DefaultColormap(display, screen), name, &color)) {
/* lets check if it's a hex colour with the # missing in front
* if yes, then do something about it */
- char newname[64];
+ char newname[DEFAULT_TEXT_BUFFER_SIZE];
newname[0] = '#';
- strncpy(&newname[1], name, 62);
+ strncpy(&newname[1], name, DEFAULT_TEXT_BUFFER_SIZE - 1);
/* now lets try again */
if (!XParseColor(display, DefaultColormap(display, screen), &newname[0],
&color)) {