Commit b0f13ece authored by Attila Kinali's avatar Attila Kinali

fix a few buffer overflows

Signed-off-by: Attila Kinali's avatarAttila Kinali <attila@kinali.ch>
parent 5c338939
......@@ -289,6 +289,7 @@ printFiles::printFiles(int argc, /* I - Number of command-line arguments */
special_opts = (special_opt_t **)calloc(sizeof(special_opt_t *),
num_dests);
num_special_opts = (int *)calloc(sizeof(int), num_dests);
// FIXME: where is menu_strs free()ed ?
menu_strs = (char **)calloc(sizeof(char *),num_dests);
menu_buttons = (Fl_Round_Button **)calloc(sizeof(Fl_Round_Button *),
num_dests);
......@@ -309,10 +310,6 @@ printFiles::printFiles(int argc, /* I - Number of command-line arguments */
special_opts[i] = NULL;
num_special_opts[i] = 0;
// Set up text for menu entry
menu_strs[i]=(char *)calloc(sizeof(char),128);
// Get printer information to show in the menu entry
ipp_t *request = CupsHelper::newIppRequest();
......@@ -320,6 +317,7 @@ printFiles::printFiles(int argc, /* I - Number of command-line arguments */
const char *state = NULL, *type = NULL, *location = NULL, *comment = NULL;
sprintf(buf,"ipp://%s:%d/printers/%s",CupsHelper::host(),
CupsHelper::port(),dests[i].name);
buf[1023] = '\0';
ippAddString(request,IPP_TAG_OPERATION,IPP_TAG_URI,"printer-uri",NULL,buf);
request->request.op.operation_id = IPP_GET_PRINTER_ATTRIBUTES;
request = CupsHelper::processRequest(request,"/printers/");
......@@ -366,25 +364,25 @@ printFiles::printFiles(int argc, /* I - Number of command-line arguments */
int prtype = CupsHelper::printerType(dests[i].name);
if ( prtype < 0 ) {
if ( dests[i].instance != NULL )
sprintf(menu_strs[i], "%s on %s: Destination not available",
asprintf(&menu_strs[i], "%s on %s: Destination not available",
dests[i].instance, dests[i].name);
else
sprintf(menu_strs[i], "%s: Destination not available",
asprintf(&menu_strs[i], "%s: Destination not available",
dests[i].name);
} else if ((prtype & CUPS_PRINTER_CLASS) ||
(prtype & CUPS_PRINTER_IMPLICIT)) {
if ( dests[i].instance != NULL )
sprintf(menu_strs[i], "%s on %s: %s (printer class)",
asprintf(&menu_strs[i], "%s on %s: %s (printer class)",
dests[i].instance, dests[i].name, comment);
else
sprintf(menu_strs[i], "%s: %s (printer class)",
asprintf(&menu_strs[i], "%s: %s (printer class)",
dests[i].name, comment);
} else {
if ( dests[i].instance != NULL )
sprintf(menu_strs[i], "%s on %s: %s (single printer)",
asprintf(&menu_strs[i], "%s on %s: %s (single printer)",
dests[i].instance, dests[i].name, comment);
else
sprintf(menu_strs[i], "%s: %s (single printer)",
asprintf(&menu_strs[i], "%s: %s (single printer)",
dests[i].name, comment);
}
......@@ -409,6 +407,7 @@ printFiles::printFiles(int argc, /* I - Number of command-line arguments */
// Small info line under printer entry
sprintf(buf," State: %s Location: %s Type: %s",
state, location, type);
buf[1023] = '\0';
info_lines[i] = new Fl_Box(FL_FLAT_BOX,
0,(ITEM_HEIGHT+INFO_HEIGHT)*i+ITEM_HEIGHT,
0, INFO_HEIGHT, strdup(buf));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment